Quickstart
This guide will help you explore the basics of interacting with the COTI network and executing transactions with encrypted inputs. To get started, choose your path (Solidity, TypeScript or Python) and follow the steps listed below.
Solidity
Clone the coti-contracts-examples repository\
git clone https://github.com/coti-io/coti-contracts-examples.gitNavigate to the newly cloned repository directory\
cd ./coti-contracts-examplesInstall dependencies\
npm installCompile contracts\
npx hardhat compileRun the PrivateToken test script\
npm run test-private-tokenRunning this test will automatically create an account and a key/value pair with name:
SIGNING_KEYS(visible in the .env file). The script will output something like this:\Private Token 1) "before all" hook in "Private Token" 0 passing (39ms) 1 failing 1) Confidential ERC20 "before all" hook in "Private Token": Error: Created new random account 0x17EDB982c3569D29EbaF407F72aDD05722d5f179. Please use faucet to fund it.It is normal to encounter exception of:
Error: Created new random account [...] Please use faucet to fund it.on the first run, This will be resolved once the account is funded.\To fund the account, head to the faucet at https://faucet.coti.io to get Testnet funds. (use https://discord.coti.io to join COTI's Discord server) Send the following message to the faucet along with your newly created account, visible in the last part of the error above. format:
testnet <account address>for example:testnet0x17EDB982c3569D29EbaF407F72aDD05722d5f179 The bot will reply with the message:<username> faucet transferred 10 COTI (testnet)\Run the
PrivateTokentest suite once more.\npm run test-private-tokenThe script output will look like this:\
Private Token ************* Onboarding user 0x17EDB982c3569D29EbaF407F72aDD05722d5f179 ************* ************* Onboarding user 0xe1E7315F6970F353661fc84FFd9238133cED3677 ************* ************* Onboarded! created user key and saved into .env file ************* ************* Onboarded! created user key and saved into .env file ************* Deployment ✔ Deployed address should not be undefined ✔ Owner initial balance (123ms) ✔ Function 'name' should be correct (130ms) ✔ Function 'symbol' should be correct (123ms) ✔ Function 'decimals' should be correct (119ms) ✔ Function 'totalSupply' should be correct (117ms) Transfer 5 ✔ Transfer - clear (9469ms) ✔ Transfer - Confidential (5260ms) ✔ TransferFrom - clear without giving allowance should fail (9905ms) ✔ TransferFrom - clear (9770ms) ✔ TransferFrom - Confidential (10265ms) ✔ Approve/Allowance - Confidential (10255ms) 12 passing (1m) ✨ Done in 69.69s.Running the test suite does the following:
Deploys the
PrivateTokencontract: Sets up the token with specific details (name, symbol, initial supply).Tests the deployment: Verifies the contract address, initial balance, and token details (name, symbol, decimals, total supply).
Tests transfers: Both clear and confidential transfers, including
transferFromfunctionality with and without prior allowance.Tests approvals and allowances: Ensures that the contract correctly handles approvals and allowances, both clear and confidential.
You may also run specific tests:\
npm run test-private-nftor\
npm run test-private-tokenor\
npm run test-private-auctionor\
npm run test-private-identity-registryor\
npm run test-on-chain-database
TypeScript
Clone the coti-typescript-examples repository\
Navigate to the coti-ethers examples subdirectory in the newly cloned repository directory\
Install dependencies\
Run the
PrivateTokenexample\Running this test will automatically create an account and a key/value pair with name:
SIGNING_KEY(visible in the .env file). The script will output something like this:\It is normal to receive the exception
Error: Please use faucet to fund accounton the first run. This will be resolved once the account is funded.\To fund the account, head to the faucet at https://faucet.coti.io to get Testnet funds. (use https://discord.coti.io to join COTI's Discord server) Send the following message to the faucet along with your newly created account, visible in the last part of the error above. format:
testnet <account address>for example:testnet 0x87c13D0f5903a68bE8288E52b23A220CeC6b1aB6The bot will reply with the message<username> faucet transferred 10 COTI (testnet)\Run the
PrivateTokenscript once more\You may also run other scripts:\
or\
or\
Python
Clone the coti-python-examples repository\
Navigate to the coti-web3 examples subdirectory in the newly cloned repository directory\
Install dependencies\
Set the python path as following\
Run the
native_transfer.pyscript\Running the script will automatically create an account and a key/value pair with name:
ACCOUNT_PRIVATE_KEY(visible in the.envfile). The script will output something like this:\It is normal to receive the exception
Not enough balance!on the first run. This will be resolved once the account is funded.\To fund the account, head to the faucet at https://faucet.coti.io to get Testnet funds. (use https://discord.coti.io to join COTI's Discord server) Send the following message to the faucet along with your newly created account, visible in the last part of the error above. format:
testnet <account address>for example:testnet 0x87c13D0f5903a68bE8288E52b23A220CeC6b1aB6The bot will reply with the message<username> faucet transferred 10 COTI (testnet)\Run the
native_transfer.pyscript once more\The script will output as following:\
Run the
onboard_account.pyscript\You may also run other scripts:\
or\
Last updated
Was this helpful?