Token deployment
Deploy using JSON configuration
To deploy a Token, you first need to build its JSON configuration Then, execute the #createFactory()
static method of the Token
class using a signer to generate a plan to deploy a Token according to its configuration.
The process will emit several progress
events that you can subscribe to follow
the deployment of the contracts and configuration steps. The method returns a deployment factory that will itself resolve to a Token object via its .deploy
method.
const tokenFactory = await Token.createFactory({ /* Configuration */ })
tokenFactory.on('fail', (event) => { console.log(event); });
tokenFactory.on('progress', (event) => { console.log(event); });
tokenFactory.on('deployed', (event) => { console.log(event); });
await tokenFactory.makePlan();
console.log(tokenFactory.plan); // Describes the steps required to deploy the token.
const token = await tokenFactory.deploy({ signer });
const tx = await token.registerIdentity();
await tx.wait();
Deploying contracts individually
const token = new Token();
token.provider = "YOUR PROVIDER"; // Set your provider (e.g., Homestead, Ropsten, etc.)
token.signer = "YOUR SIGNER"; // Set your signer, the wallet used to sign transactions
await token.deployClaimTopicsRegistry();
await token.deployTrustedIssuersRegistry();
// ClaimTopics and TrustedIssuers are required to Deploy Identity Registry
await token.deployIdentityRegistry();
await token.deployCompliance();
// Identity Registry and Compliance are required to Deploy Token
await token.deployToken({
name: 'Some Token name',
symbol: 'SYMBOL',
decimals: 8,
onchainID: '0x... Security ID address...',
implementationAuthority: '0x... implementation authority address ...',
});
The token is deployed as a proxy contract, with its own storage, but using the implementation as managed by the implementation authority contract. The implementation authority can be the Tokeny Beacon, or a custom one.
Once deployed, you can get smart contracts addresses by using:
const tokenAddress = token.getTokenAddress();
const identityAddress = token.getIdentityRegistryAddress();
const complianceAddress = token.getComplianceAddress();
const claimTopicsAddress = token.getClaimTopicsRegistryAddress();
const trustedIssuers = token.getTrustedIssuersRegistryAddress();
Redeploy Token only
If you need to redeploy a Token, for example, you need to re-issue a Token without redeploying all the smart contracts, and an IdentityRegistry and/or Compliance already exists, you can deploy the Token by loading both contracts.
const token = new Token();
await token.loadIdentityRegistry(
"IDENTITY REGISTRY ADDRESS"
);
await token.loadCompliance("COMPLIANCE ADDRESS");
await token.deployToken();
Updated 14 days ago