Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async buildDeployTransaction() {
const { DeployTransactionBuilder } = IconBuilder;
const initialSupply = IconConverter.toBigNumber("100000000000");
const decimals = IconConverter.toBigNumber("18");
const tokenName = "StandardToken";
const tokenSymbol = "ST";
const contentType = "application/zip";
// Enter token information
// key name ("initialSupply", "decimals", "name", "symbol")
// You must enter the given values. Otherwise, your transaction will be rejected.
const params = {
initialSupply: IconConverter.toHex(initialSupply),
decimals: IconConverter.toHex(decimals),
name: tokenName,
symbol: tokenSymbol
}
const installScore = MockData.SCORE_INSTALL_ADDRESS;
const stepLimit = await this.getMaxStepLimit();
const walletAddress = this.wallet.getAddress();
// networkId of node 1:mainnet, 2~:etc
const networkId = IconConverter.toBigNumber(3);
const version = IconConverter.toBigNumber(3);
// Timestamp is used to prevent the identical transactions. Only current time is required (Standard unit : us)
// If the timestamp is considerably different from the current time, the transaction will be rejected.
const timestamp = (new Date()).getTime() * 1000;
//Enter transaction information
const deployTransactionBuilder = new DeployTransactionBuilder();
async buildDeployTransaction() {
const { DeployTransactionBuilder } = IconBuilder;
const initialSupply = IconConverter.toBigNumber("100000000000");
const decimals = IconConverter.toBigNumber("18");
const tokenName = "StandardToken";
const tokenSymbol = "ST";
const contentType = "application/zip";
// Enter token information
// key name ("initialSupply", "decimals", "name", "symbol")
// You must enter the given values. Otherwise, your transaction will be rejected.
const params = {
initialSupply: IconConverter.toHex(initialSupply),
decimals: IconConverter.toHex(decimals),
name: tokenName,
symbol: tokenSymbol
}
const installScore = MockData.SCORE_INSTALL_ADDRESS;
const stepLimit = await this.getMaxStepLimit();
const walletAddress = this.wallet.getAddress();
// networkId of node 1:mainnet, 2~:etc
const networkId = IconConverter.toBigNumber(3);
const version = IconConverter.toBigNumber(3);
// Timestamp is used to prevent the identical transactions. Only current time is required (Standard unit : us)
// If the timestamp is considerably different from the current time, the transaction will be rejected.
const timestamp = (new Date()).getTime() * 1000;
//Enter transaction information
const deployTransactionBuilder = new DeployTransactionBuilder();
const transaction = deployTransactionBuilder
// You can use "governance score apis" to get step costs.
const value = IconAmount.of(1, IconAmount.Unit.ICX).toLoop();
const stepLimit = await this.getDefaultStepCost();
// networkId of node 1:mainnet, 2~:etc
const networkId = IconConverter.toBigNumber(3);
const version = IconConverter.toBigNumber(3);
// Timestamp is used to prevent the identical transactions. Only current time is required (Standard unit : us)
// If the timestamp is considerably different from the current time, the transaction will be rejected.
const timestamp = (new Date()).getTime() * 1000;
// SCORE name that send transaction is “transfer”.
const methodName = "transfer";
// Enter receiving address and the token value.
// You must enter the given key name("_to", "_value"). Otherwise, the transaction will be rejected.
const params = {
_to: MockData.WALLET_ADDRESS_2,
_value: IconConverter.toHex(value)
}
//Enter transaction information
const tokenTransactionBuilder = new CallTransactionBuilder();
const transaction = tokenTransactionBuilder
.nid(networkId)
.from(walletAddress)
.to(this.scoreAddress)
.stepLimit(stepLimit)
.timestamp(timestamp)
.method(methodName)
.params(params)
.version(version)
.build();
return transaction;
}
// You can use "governance score apis" to get step costs.
const value = IconAmount.of(1, IconAmount.Unit.ICX).toLoop();
const stepLimit = this.getDefaultStepCost();
// networkId of node 1:mainnet, 2~:etc
const networkId = IconConverter.toBigNumber(3);
const version = IconConverter.toBigNumber(3);
// Timestamp is used to prevent the identical transactions. Only current time is required (Standard unit : us)
// If the timestamp is considerably different from the current time, the transaction will be rejected.
const timestamp = (new Date()).getTime() * 1000;
// SCORE name that send transaction is “transfer”.
const methodName = "transfer";
// Enter receiving address and the token value.
// You must enter the given key name("_to", "_value"). Otherwise, the transaction will be rejected.
const params = {
_to: MockData.WALLET_ADDRESS_2,
_value: IconConverter.toHex(value)
}
//Enter transaction information
const tokenTransactionBuilder = new CallTransactionBuilder();
const transaction = tokenTransactionBuilder
.nid(networkId)
.from(walletAddress)
.to(MockData.TOKEN_ADDRESS)
.stepLimit(stepLimit)
.timestamp(timestamp)
.method(methodName)
.params(params)
.version(version)
.build();
return transaction;
}