COTI V2 Documentation
  • Welcome
  • Networks
    • Faucet
    • Contracts Addresses
    • Adding the COTI Network to Metamask
  • How COTI Works
    • Introduction
      • EVM Introduction
      • Conceptual Overview
      • Use Cases and Applications
      • COTI Architecture
    • Advanced Topics
      • Garbled Circuits
      • AES Keys
      • Precompiles
      • Whitepaper
      • COTI vs others
  • Build on COTI
    • Core Concepts
      • Account Onboarding Procedure
      • Private Data Types
      • Supported Operations on Private Data Types
    • Quickstart
    • Guides
      • Basic Private Smart Contract
      • Account Onboard
      • Sending a Transaction with Encrypted Inputs
      • Resolving a Transaction's Encrypted Outputs
      • Writing a Private Smart Contract
      • Dos and Don'ts
        • Proper Use of Types
        • No Constant/Immutable Secret Types
        • No Public Contract Variables
      • Best Practices
        • Careful Onboarding
        • Careful Decrypting
        • Don't loop over an array without an index
        • Check Overflow
    • Tools
      • TypeScript SDK
      • Ethers.js
      • Python SDK
      • Web3.py
      • Contracts Library
        • MPC Core
        • Data Privacy Framework
        • Tokens
          • Private ERC20
          • Private ERC721
        • Onboard
      • Hardhat
      • Remix Plugin
      • COTI MetaMask Snap
      • Developer Sandbox
  • Running a COTI Node
    • COTI Node Ecosystem Litepaper
  • COTI Bridge
    • Swap COTI V1 Funds to COTI V2
  • Support and Community
    • Glossary
    • Telegram
    • Discord
    • GitHub
    • X
    • YouTube
  • COTI Builders Program
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Build on COTI
  2. Guides

Account Onboard

PreviousBasic Private Smart ContractNextSending a Transaction with Encrypted Inputs

Last updated 4 months ago

Was this helpful?

This guide assumes you have already deployed the Counter.sol contract. If you haven't already, check out our guide for deploying a .

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 or packages to complete the .

Setup

npm install @coti-io/coti-ethers

Code

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-ethers

Code

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-web3

Code

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)
Basic Private Smart Contract
Ethers
web3.py
Account Onboarding Procedure