Skip to main content

Create Tokens via Portkey AA Address

1. Obtain SEED

Refer to Obtain SEED

2. Create token

Create by using ManagerForwardCall in the AA contract and calling the Token contract.

Please note: the contract called is on the MainChain but you can decide to create tokens whether on the MainChain or dAppChains via the parameter issue_chain_id (issueChainId in the below demo).

Obtain chain information

You can use the methods below to query each chain's info and the info about the AA contract or Token contract. Select MainChain AELF as the token creation chain.

import { did } from '@portkey/did';
const chainList = await did.services.getChainsInfo();

Obtain wallet information

Please note: the Portkey account should be logged in.

import { did } from '@portkey/did';

const { wallet } = did.didWallet.managementAccount;

Initialize contract

import { getContractBasic } from '@portkey/contracts';

const contract = await getContractBasic({
contractAddress: TOKEN_CONTRACT_ADDRESS, // MultiToken contract address
account: wallet, // Provide the wallet info from the last step
callType: 'ca', // Set the initialising contract type as AA contract
caContractAddress: 'AA contract address',
caHash: did.didWallet.caInfo.AELF.caHash, // CaHash of the account
rpcUrl: 'aelf blockchain node address'
});

Create by calling contract methods

For parameter details, refer to contract documentation: https://docs.aelf.io/en/latest/reference/smart-contract-api/multi-token.html

Create by using the callSendMethod method in the AA contract and calling the Token contract.

const { data: { TransactionId } } = await contract.callSendMethod('Create', wallet.address, {
symbol: 'TEST TOKEN',
tokenName: 'TEST TOKEN NAME',
totalSupply: 'Total amount of tokens can be created',
decimals: 'token decimals',
issuer: 'Target issuer address',
isBurnable: 'Set the token to be burnable or not',
issueChainId: 'ID of the chain where the token will be issued',
});

3. Issue

Issue by using the callSendMethod method in the AA contract and calling the Token contract.

const result = await contract.callSendMethod('Issue', wallet.address, {
symbol: 'TEST TOKEN',
to: 'Target issuer' ,
amount: 'Total amount of tokens can be issued'
});

Process of Portkey account creating tokens

AA operation --- set MainChain as issue_chain_id

set-side-chain

AA operation --- set dAppChain as issue_chain_id

Operations on the dAppChain can only take effect when the MainChain and dAppChain are synchronized.

set-side-chain