Custom Contract Interaction
Demonstrate how to execute contract calls using Etherspot SDK
Before we continue...
import {
Sdk as EtherspotSdk,
NetworkNames,
randomPrivateKey,
} from 'etherspot';
// ...
// First, define the contract address and abi
const contractAddress = '0x4D70a031Fc76DA6a9bC0C922101A05FA95c3A227';
// For the sake of example, we are only defining the method we are going to execute
const contractAbi = [
"function stake(uint256 value)",
];
// Next, instantiate our SDK on Matic as the contract address is on the same chain
const etherspotSdk = new EtherspotSdk({
privateKey: randomPrivateKey(),
}, {
networkName: NetworkNames.Matic,
});
// Finally, compute the contract account addresses ahead of time
// The responses will return the account details.
const maticAccount = await etherspotSdk.computeContractAccount();Create Contract Interface using Etherspot SDK
Adding your transaction to a batch
Estimating your batch
Submitting your batch
🎉 Finished!
Last updated
Was this helpful?