🎫Deploy a Wallet


This script:

  1. Checks and mint test Kinto IDs for a given EOA

  2. Create KintoWallets for KYC'd EOAs

This script is meant to be used on your local fork. If you are using mainnet, you must head to https://engen.kinto.xyz to KYC and create a Kinto Wallet.

Step 1: We set up the forge script, Kinto utilities will be checking that AA is properly deployed and getting the contract addresses needed for the Kinto ID, the EntryPoint, the KintoWalletFactory and the SponsorPaymaster.

contract KintoDeployTestWalletScript is AASetup, KYCSignature {

    using ECDSAUpgradeable for bytes32;
    using SignatureChecker for address;

    KintoID _kintoID;
    EntryPoint _entryPoint;
    KintoWalletFactory _walletFactory;
    SponsorPaymaster _sponsorPaymaster;
    IKintoWallet _newWallet;

    function setUp() public {
        uint256 deployerPrivateKey = vm.envUint('PRIVATE_KEY');
        (_kintoID, _entryPoint, _walletFactory, _sponsorPaymaster) = _checkAccountAbstraction();

Step 2: At the beginning, we take the deployer private key (this is the key of the address that has deployed the contracts in your chain). After that, through the Kinto ID, we check if the intended recipient wallet has already been KYC'd. If it has not been KYC'd yet we mint the Kinto ID (on Kinto mainnet this will happen automatically after the KYC/KYB process).

    function run() public {
        uint256 deployerPrivateKey = vm.envUint('PRIVATE_KEY');
        uint256 recipientKey = vm.envUint('TEST_PRIVATE_KEY');
        address recipientWallet = vm.rememberKey(vm.envUint("TEST_PRIVATE_KEY"));

        console.log('All AA setup is correct');
        uint totalWalletsCreated =  _walletFactory.totalWallets();
        if(!_kintoID.isKYC(recipientWallet)) {
            IKintoID.SignatureData memory sigdata = _auxCreateSignature(
                _kintoID, recipientWallet,
                recipientKey, block.timestamp + 1000);
            uint16[] memory traits = new uint16[](0);
            _kintoID.mintIndividualKyc(sigdata, traits);

Step 3: Finally, once we ensure that the EOA intended to become the first signer of a wallet has the Kinto ID we are ready to use the KintoWalletFactory to create a smart account.

        console.log('This factory has', totalWalletsCreated, ' created');
        uint salt = 0;
        address newWallet = _walletFactory.getAddress(recipientWallet, recipientWallet, salt);
        if (isContract(newWallet)) {
            console.log('Wallet already deployed for owner', recipientWallet, 'at', newWallet);
        } else {
            IKintoWallet ikw = _walletFactory.createAccount(recipientWallet, recipientWallet, salt);
            console.log('Created wallet', address(ikw));
            console.log('Total Wallets:', _walletFactory.totalWallets());

TIP: If you want to create more than one wallet, rerun the script and modify the salt variable.

Last updated