Source repository for smart contracts used by Circle's stablecoins on Aptos blockchain
Before you can start working with the contracts in this repository,
-
[Optional] Create a directory to store Aptos-related binaries:
mkdir -p $HOME/.aptos/bin/ echo 'export APTOS_BIN="$HOME/.aptos/bin"' >> ~/.zshrc echo 'export PATH="$APTOS_BIN:$PATH"' >> ~/.zshrc
-
Install the necessary tools
make setup
A guide on installing the CLI tools in other environments can be found here.
The recommended IDE for this repository is VSCode. To get your IDE set up:
-
Install the recommended extensions in VSCode. Enter
@recommended
into the search bar in the Extensions panel and install each of the extensions -
Install the
aptos-move-analyzer
binary, ensuring that it can be found on your PATHmkdir -p $HOME/.aptos/bin/ curl -L -o "$HOME/.aptos/bin/aptos-move-analyzer" "https://github.com/movebit/aptos-move-analyzer/releases/download/v1.0.0/aptos-move-analyzer-mac-x86_64-v1.0.0" chmod +x $HOME/.aptos/bin/aptos-move-analyzer echo 'export PATH="$HOME/.aptos/bin:$PATH"' >> ~/.zshrc
-
Run all Move tests:
make test
Coverage info is printed by default with this command.
-
Code formatting:
make fmt
To test the contracts on a localnet:
-
Start the local network.
make start-network
-
Create a local account and fund it with APT
make create-local-account
-
Deploy
aptos_extensions
andstablecoin
packages, and initialize stablecoin stateyarn scripts deploy-and-initialize-token \ -r http://localhost:8080 \ --deployer-key <PRIVATE_KEY> \ --token-config-path ./scripts/typescript/resources/default_token.json
[!NOTE]
- The private key can be found inside
.aptos/keys/deployer.key
. - The deployment uses default configurations inside "./scripts/typescript/resources/default_token.json". For a real deployment, please make a copy of
scripts/typescript/resources/usdc_deploy_template.json
and fill in all settings.
- The private key can be found inside
-
[Optional] Upgrade the
stablecoin
packagesyarn scripts upgrade-stablecoin-package \ -r http://localhost:8080 \ --admin-key <PRIVATE_KEY> \ --payload-file-path <PUBLISH_PAYLOAD_FILE_PATH> \ --aptos-extensions-package-id <ADDRESS> \ --stablecoin-package-id <ADDRESS>
-
Create a deployer keypair and fund it with APT
If deploying to a test environment (local/devnet/testnet), you can create and fund the account with the following CLI command
# Local yarn scripts generate-keypair --prefund # Devnet yarn scripts generate-keypair --prefund --rpc-url "https://api.devnet.aptoslabs.com" --faucet-url "https://faucet.devnet.aptoslabs.com" # Testnet yarn scripts generate-keypair --prefund --rpc-url "https://api.testnet.aptoslabs.com" --faucet-url "https://faucet.testnet.aptoslabs.com"
If deploying to mainnet, create a keypair and separately fund the account by purchasing APT.
yarn scripts generate-keypair
-
Create token configuration by copying existing template.
cp scripts/typescript/resources/usdc_deploy_template.json scripts/typescript/resources/<CONFIG_FILE_NAME>
Fill out all configuration parameters.
-
Deploy
aptos_extensions
andstablecoin
packages, and initialize stablecoin stateyarn scripts deploy-and-initialize-token \ -r http://localhost:8080 \ --deployer-key <PRIVATE_KEY> \ --token-config-path <TOKEN_CONFIG_FILE_PATH>
Source code verification is disabled by default, but can be enabled via the
--verify-source
flag.
We have provided scripts that enable developers to interact with a deployed token. To view a list of available scripts and their options, use the following command:
yarn scripts --help
If you want to see the specific options for a particular script, replace <SCRIPT_NAME>
with the name of the script and run:
yarn scripts <SCRIPT_NAME> --help