EVM

evm()

Creates an EvmBuilder class instance, which provides methods to build transactions for the EVM Pallet on The Root Network. It expects four parameters:

  • api: the API instance.

  • signer: the Signer instance.

  • walletAddress: the walletAddress to send the extrinsic from.

  • contractAddress: the contract address to target. Optional parameter.

Example:

const evmBuilder = await TransactionBuilder.evm(api, signer, walletAddress, contractAddress);

The evmBuilder Class behaves differently from the other builders regarding the FuturePass and FeeProxy logic. To use FuturePass, you need to set the fromFuturePass flag to true when calling the writeContract method.

The evm method provides developers with two methods, evmOverride and writeContract, and two helper functions, addFuturePass and addFeeProxy.

addFeeProxy()

Helper function to add a FeeProxy to the extrinsic. It expects two parameters:

  • assetId: the asset ID to pay the fee in (1 for ROOT, 2 for XRP, 3 for Vortex, etc).

  • slippage: the slippage to use for the fee - in percentage.

Example:

const evmBuilder = await TransactionBuilder.evm(api, signer, walletAddress, contractAddress).addFeeProxy(assetId, slippage);

addFuturePass()

Helper function to add a FuturePass Proxy to the extrinsic. It expects one parameter:

  • futurePass - the Futurepass to proxy the extrinsic through.

Example:

const evmBuilder = await TransactionBuilder.evm(api, signer, walletAddress, contractAddress).addFuturePass(futurePass);

evmOverride()

Call to interact with the EVM with data already encoded. Initially designed for internal use only as a way to override an EVM call made through Wagmi with the Xaman Connector. It can receive six parameters:

  • to: the address sending the transaction to. Optional parameter.

  • data: the data to send with the transaction.

  • value: the value to send with the transaction. Optional parameter.

  • maxPriorityFeePerGas: the max priority fee per Gas to use or null. Optional parameter.

  • nonce: the nonce to use for the transaction or null. Optional parameter.

  • fromFuturePass: boolean to whether to use the FuturePass for the transaction. Optional parameter. Defaults to false.

If to is omitted, the function will fallback to the contractAddress used when instantiating the class if one exists; otherwise, it will fail.

Example:

const evmBuilder = await TransactionBuilder.evm(api, signer, walletAddress, contractAddress).evmOverride(data);

writeContract()

Call to interact with a contract on the EVM. The function will encode the function data and prepare the transaction when the appropriate parameters are passed. It can receive up to eight parameters:

  • to: the address sending the transaction to. Optional parameter.

  • abi: the ABI of the contract to call.

  • functionName: the name of the function to call.

  • args: array of arguments to pass to the function. Optional parameter.

  • fromFuturePass: boolean to whether to use the FuturePass for the transaction. Optional parameter.

  • value: the value to send with the transaction. Optional parameter.

  • maxPriorityFeePerGas: the max priority fee per Gas to use or null. Optional parameter.

  • nonce: the nonce to use for the transaction or null. Optional parameter.

If to is omitted, the function will fallback to the contractAddress used when instantiating the class if one exists; otherwise, it will fail.

Example:

const evmBuilder = await TransactionBuilder.evm(api, signer, walletAddress, contractAddress).writeContract(abi, functionName);

Last updated

© 2023 -> ♾️