π€Interacting with contracts
All users in Kinto are forced to interact with contracts by sending UserOps through the Kinto EntryPoint. In this guide we will learn to create and send UserOps.
Last updated
All users in Kinto are forced to interact with contracts by sending UserOps through the Kinto EntryPoint. In this guide we will learn to create and send UserOps.
Last updated
contract KintoIncrementTest is MigrationHelper {
//Migration helper contains useful functions to interact with the Kinto chain
//Grab your signer private key, kinto wallet and counter deployed in previous guides
uint256 walletSignerKey = vm.envUint("KINTO_WALLET_SIGNER_KEY");
address kintoWalletAddress = vm.envAddress("KINTO_WALLET");
Counter counter = Counter(0xyourAddressHere);
console.log("Before UserOp. Counter:", counter.count());
//Setup kinto wallet
IKintoWallet _kintoWallet;
_kintoWallet = IKintoWallet(kintoWalletAddress);
uint256 nonce = _kintoWallet.getNonce();
//Setup signers for the kinto wallet
uint256[] memory privateKeys = new uint256[](1);
privateKeys[0] = walletSignerKey;
//Create a userOp array
UserOperation[] memory userOps = new UserOperation[](2);
// whitelist counter contract in the wallet
address[] memory targets = new address[](1);
targets[0] = address(counter);
bool[] memory flags = new bool[](1);
flags[0] = true;
//First userOp will whitelist the application
userOps[0] = _createUserOperation(
block.chainid,
address(_kintoWallet),
address(_kintoWallet),
0,
nonce,
privateKeys,
abi.encodeWithSignature("whitelistApp(address[],bool[])", targets, flags),
address(paymaster)
);
// increment counter
userOps[1] = _createUserOperation(
block.chainid,
address(_kintoWallet),
address(counter),
0,
nonce + 1,
privateKeys,
abi.encodeWithSignature("increment()"),
address(paymaster)
);
vm.broadcast(walletSignerKey);
entryPoint.handleOps(userOps, payable(walletSignerKey));
}