If you’re unsure about the difference between key based accounts and smart contract
accounts, please take a look at this pageIn this example we simply create a key based wallet with ethers.js like so:
Now that we have a smart contract account on Coston2, we can fund
it using Flare’s offical faucet.Once we have funds on our account (you can check this here)
we can try a simple send operation. This can be done through creating a sendFunds function like so:We’ll want to save destinationAddress and amount in some input field within the dapp.
Copy
const sendFunds = async () => { const primeSdk = new PrimeSdk({ privateKey: eoaPrivateKey}, { chainId: 114, bundlerProvider: new EtherspotBundler(114, bundlerApiKey) }); // clear the transaction batch await primeSdk.clearUserOpsFromBatch(); // add transactions to the batch const transactionBatch = await primeSdk.addUserOpsToBatch({to: destinationAddress, value: ethers.utils.parseEther(destinationAddress)}); // estimate transactions added to the batch and get the fee data for the UserOp const op = await primeSdk.estimate(); // sign the UserOp and send to bundler const uoHash = await primeSdk.send(op); console.log(`UserOpHash: ${uoHash}`);}