Account Onboard
In order to interact with the Counter.sol smart contract from the previous section, we are going to need to acquire our AES encryption key. To do so, we can use either of COTI's Ethers or web3.py packages to complete the Account Onboarding Procedure.
Setup
npm install @coti-io/coti-ethersCode
import { CotiNetwork, getDefaultProvider, Wallet } from "@coti-io/coti-ethers"
const PRIVATE_KEY = "<EOA_PRIVATE_KEY>"
const provider = getDefaultProvider(CotiNetwork.Testnet)
const wallet = new Wallet(PRIVATE_KEY, provider)
await wallet.generateOrRecoverAes()
console.log(wallet.getUserOnboardInfo()?.aesKey)Setup
npm install @coti-io/coti-ethersCode
import { BrowserProvider, Eip1193Provider, JsonRpcSigner } from '@coti-io/coti-ethers'
const provider = new BrowserProvider(window.ethereum as Eip1193Provider)
const signer = await provider.getSigner()
await signer.generateOrRecoverAes()
console.log(signer.getUserOnboardInfo()?.aesKey)Setup
pip install coti-web3Code
from eth_account import Account
from eth_account.signers.local import LocalAccount
from web3 import Web3
from web3.utils.coti import (
CotiNetwork,
generate_or_recover_aes,
init_web3
)
PRIVATE_KEY = "<EOA_PRIVATE_KEY>"
account: LocalAccount = Account.from_key(PRIVATE_KEY)
w3: Web3 = init_web3(CotiNetwork.TESTNET)
generate_or_recover_aes(w3, account)
print(account.aes_key)Last updated
Was this helpful?