This guide is intended to explain more about the interaction and deployment of the Smart Wallets. We will be using additional testing contracts that were included in the project, like the UtilToken(ERC20)
. All the utils scripts are executed from the account[0] from the regtest network.
There are two ways to create a Smart Wallet:
In the RIF Relay Contracts there is a script that would help us to mint ERC20 tokens.
We need to execute the following script:
npx hardhat mint --token-address <0xabc123> --amount <amount_in_wei> --receiver <0xabc123> --network regtest
The token contract needs to have a mint function.
To deploy a smart wallet we need to follow some steps that will be described below:
getSmartWalletAddress
from the relay client library.
A Smart Wallet only needs to be deployed when we need to execute a transaction. The deployment process uses gas so, unless it’s subsidized, we need to pay for it.
At this point we should have the Relay Client object created.
import type {
getSmartWalletAddress,
UserDefinedDeployRequest,
} from '@rsksmart/rif-relay-client';
const smartWalletAddress = await getSmartWalletAddress(<EOA>, <INDEX>);
const relayTransactionOpts: UserDefinedDeployRequest = {
request: {
from: <EOA>,
tokenContract: <TOKEN_ADDRESS>,
tokenAmount: <AMOUNT_OF_TOKENS_IN_WEI>,
index: <INDEX>,
},
};
const transaction = await relayClient.relayTransaction(
relayTransactionOpts
);
Keep in mind that to pay any amount of token fees during the deployment, the smart wallet must receive funds first.
Where variables are:
Go to top