In this example we show how to deploy a PANDAS-based Token using Brownie
Prerequisites
Install Brownie: pip install eth-brownie
Add your custom token contract to the contracts folder in your Brownie project.
Add your private key to the brownie project
If you have already a private key, use: brownie accounts new <id>
If you don't have a private key, use: brownie accounts generate <id>
Do not forget to request testnet funds from the faucets
Modify the networks-config.yaml to include the desired testnets.
Step 1: Configure the networks-config.yaml
Update the networks-config.yaml file to include the testnet configurations for Ethereum (Goerli), BNB Chain (Testnet), Avalanche (Fuji), Fantom (Testnet), Celo (Alfajores), and Cronos (Testnet).
Step 3: Deploy and register your token on each supported testnet
In your Brownie project, create a scripts directory and add a file named deploy_token.py and add the following code:
import brownieimport jsonfrom brownie import MyToken# Set initial token supply and minimum token stakeINITIAL_SUPPLY =100*10**18# initial supply is 100 Token with 18 decimals_MINIMUM_TOKEN_STAKE =1# Set the addresses for the Pantos forwarder, hub, and PAN tokenFORWARDER_ADDRESS ="get address bottom of this page"HUB_ADDRESS ="get address bottom of this page"PAN_ADDRESS ="get address bottom of this page"# Define the deployToken functiondefdeploy_token(account_name:str):# loading Pantos Hub abi datawithopen('./path/to/pantos_hub_abi.json', 'r')as f: pantos_hub_abi_data = json.loads(f.read())# loading Pantos Token abi datawithopen('./path/to/pantos_token_abi.json', 'r')as f: pantos_token_abi_data = json.loads(f.read())# Load the PantosHub contract from the ABI hub = brownie.Contract.from_abi("PantosHub", HUB_ADDRESS, pantos_hub_abi_data['abi'])# Load the PantosToken contract from the ABI pan_token = brownie.Contract.from_abi("PantosToken", PAN_ADDRESS, pantos_token_abi_data['abi'])# Load the specified account account = brownie.accounts.load(account_name)# Deploy the custom token contract myTokenContract = MyToken.deploy(INITIAL_SUPPLY, {'from': account})# Set the Pantos forwarder address in the custom token contract myTokenContract.setPantosForwarder(FORWARDER_ADDRESS, {'from': account})# Approve the PantosHub to spend the required minimum token stake pan_token.approve(HUB_ADDRESS, _MINIMUM_TOKEN_STAKE, {'from': account})# Register the custom token on the PantosHub hub.registerToken(myTokenContract.address, _MINIMUM_TOKEN_STAKE, {'from': account})
Set the FORWARDER_ADDRESS, HUB_ADDRESS & PAN_ADDRESS with the appropriate addresses for each testnet.
Step 4: Register external tokens on each Pantos Hub
registerExternalToken is a function used in the Pantos ecosystem to establish a connection between a token on one blockchain and its corresponding token on another blockchain. This function enables the PantosHub to recognize the token's presence across multiple blockchains and helps facilitate cross-chain token transfers.
Create a file named register_external_tokens.py in the scripts directory of your Brownie project and add the following code:
import browniedefregister_token(account_name:str):withopen('./path/to/pantos_hub_abi.json', 'r')as f: pantos_hub_abi_data = json.loads(f.read())# Load the PantosHub contract from the ABI hub = brownie.Contract.from_abi("PantosHub", HUB_ADDRESS, pantos_hub_abi_data['abi'])# Load the specified account account = brownie.accounts.load(account_name)# Call the registerExternalToken function from the PantosHub contract# Replace the placeholders with the correct data:# - <address of token on chain>: the address of your token on the current chain# - <chain id>: the ID of the blockchain where the external token is located# - <address of token on different chain>: the address of your token on the external chain hub.registerExternalToken(<address of token on chain>,<chain id>,<address of token on different chain>.encode('utf-8').strip(), {'from': account} )
Replace <address of token on chain>, <chain id> & <address of token on different chain> with the appropriate addresses for each testnet.
Run the script on each testnet using Brownie:
brownie run ./scripts/register_external_tokens.py register_token <name of account> --network <network name>
Once you have completed these steps, your token will be deployed on all the supported testnets and registered with the Pantos Hubs. This will enable your token to be transferred across these networks seamlessly.
To summarize, this step-by-step guide will help you deploy your token on multiple testnets and register it with the Pantos Hubs. You will need to create a Brownie project, configure the necessary networks, deploy your token, and run the appropriate scripts to register your token and external tokens on each Pantos Hub. By following these steps, you'll have a multichain token that can be used across different blockchain networks.