Specify installed contracts to external contracts section of locklift config, by providing path to contracts artifacts (.abi.json files, .tvc files etc., most commonly placed in a build folder of smart contracts projects) and contract names array.
Let's move to deploy action. Firstly, we make a new deploy script in scripts directory for TokenRoot contract.
01-deploy-token-root.ts
import { Address, getRandomNonce, toNano, zeroAddress } from "locklift"
import BigNumber from "bignumber.js"
async function main() {
const signer = (await locklift.keystore.getSigner("0"))!
// Address of initial token supply recipient (write your own)
const initialSupplyTo = new Address("0:7542...")
// Address of token owner (write your own)
const rootOwner = new Address("0:7542...")
// Name of the token
const name = "First Venom Token"
// Symbol of the token
const symbol = "FVT"
// How many token will be issued instantly after deploy
const initialSupply = 0
// The number of decimals the token uses
const decimals = 18
// If `true`, disables token minting
const disableMint = false
// If `true`, disables token burning by root
const disableBurnByRoot = false
// If `true`, pauses token burning
const pauseBurn = false
/*
Returns compilation artifacts based on the .sol file name
or name from value config.externalContracts[pathToLib].
*/
const TokenWallet = locklift.factory.getContractArtifacts("TokenWallet")
/*
Deploy the TIP-3 Token Root contract.
@params deployWalletValue: Along with the deployment of the root token,
the wallet will be automatically deployed to the owner.
This is the amount of EVERs that will be sent to the wallet.
*/
const { contract: tokenRoot } = await locklift.factory.deployContract({
contract: "TokenRoot",
publicKey: signer.publicKey,
initParams: {
deployer_: zeroAddress, // this field should be zero address if deploying with public key (see source code)
randomNonce_: getRandomNonce(),
rootOwner_: rootOwner,
name_: name,
symbol_: symbol,
decimals_: decimals,
walletCode_: TokenWallet.code,
},
constructorParams: {
initialSupplyTo: initialSupplyTo,
initialSupply: new BigNumber(initialSupply).shiftedBy(decimals).toFixed(),
deployWalletValue: toNano(1),
mintDisabled: disableMint,
burnByRootDisabled: disableBurnByRoot,
burnPaused: pauseBurn,
remainingGasTo: zeroAddress,
},
value: toNano(5),
})
console.log(`${name}: ${tokenRoot.address}`)
}
main()
.then(() => process.exit(0))
.catch(e => {
console.log(e)
process.exit(1)
})
Finally, we can deploy a new token to local network. For this, make sure local node is running, if not follow the next command
docker run -d --name local-node -e USER_AGREEMENT=yes -p80:80 tonlabs/local-node
and run the deploy script
npx locklift run -s ./scripts/01-deploy-token.ts -n local
> Found 1 sources
> factorySource generated
> Built
> First Venom Token: 0:69f2407386ca20390878565da97124be717f65496cb03e14aaa676709a6ccb2b
Congratulations, your first token on the Venom network has been deployed!