How to use the icon-sdk-js.IconConverter.toBigNumber function in icon-sdk-js

To help you get started, we’ve selected a few icon-sdk-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github icon-project / icon-sdk-js / quickstart / example / js / DeployAndTransferTokenExample.js View on Github external
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
            .nid(networkId)
            .from(walletAddress)
            .to(installScore)
            .stepLimit(stepLimit)
            .timestamp(timestamp)
            .contentType(contentType)
            .content(`0x${this.content}`)
            .params(params)
            .version(version)
github icon-project / icon-sdk-js / quickstart / example / js / DeployAndTransferTokenExample.js View on Github external
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();
github icon-project / icon-sdk-js / quickstart / example / js / DeployAndTransferTokenExample.js View on Github external
const methodName = 'getStepCosts';
        // Check input and output parameters of api if you need
        const getStepCostsApi = governanceApi.getMethod(methodName);
        const getStepCostsApiInputs = getStepCostsApi.inputs.length > 0 ? JSON.stringify(getStepCostsApi.inputs) : 'none';
        const getStepCostsApiOutputs = getStepCostsApi.outputs.length > 0 ? JSON.stringify(getStepCostsApi.outputs) : 'none';
        console.log(`[getStepCosts]\n inputs: ${getStepCostsApiInputs} \n outputs: ${getStepCostsApiOutputs}`);

        // Get step costs by iconService.call
        const callBuilder = new CallBuilder();
        const call = callBuilder
            .to(MockData.GOVERNANCE_ADDRESS)
            .method(methodName)
            .build();
        const stepCosts = await this.iconService.call(call).execute();
        // For sending token, it is about twice the default value.
        return IconConverter.toBigNumber(stepCosts.default).times(2)
    }
github icon-project / icon-sdk-js / quickstart / example / js / IcxTransactionExample.js View on Github external
async buildICXTransaction() {
        const { IcxTransactionBuilder } = IconBuilder;

        const walletAddress = this.wallet.getAddress();
        // 1 ICX -> 1000000000000000000 conversion
        const value = IconAmount.of(1, IconAmount.Unit.ICX).toLoop();
        // You can use "governance score apis" to get step costs.
        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;
        
        //Enter transaction information
        const icxTransactionBuilder = new IcxTransactionBuilder();
        const transaction = icxTransactionBuilder
            .nid(networkId)
            .from(walletAddress)
            .to(MockData.WALLET_ADDRESS_2)
            .value(value)
            .stepLimit(stepLimit)
            .timestamp(timestamp)
            .version(version)
            .build();
github icon-project / icon-sdk-js / quickstart / example / js / IcxTransactionExample.js View on Github external
async buildICXTransaction() {
        const { IcxTransactionBuilder } = IconBuilder;

        const walletAddress = this.wallet.getAddress();
        // 1 ICX -> 1000000000000000000 conversion
        const value = IconAmount.of(1, IconAmount.Unit.ICX).toLoop();
        // You can use "governance score apis" to get step costs.
        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;
        
        //Enter transaction information
        const icxTransactionBuilder = new IcxTransactionBuilder();
        const transaction = icxTransactionBuilder
            .nid(networkId)
            .from(walletAddress)
            .to(MockData.WALLET_ADDRESS_2)
            .value(value)
            .stepLimit(stepLimit)
            .timestamp(timestamp)
            .version(version)
            .build();        
        return transaction;
github icon-project / icon-sdk-js / quickstart / example / js / TokenTransactionExample.js View on Github external
const methodName = 'getStepCosts';
        // Check input and output parameters of api if you need
        const getStepCostsApi = governanceApi.getMethod(methodName);
        const getStepCostsApiInputs = getStepCostsApi.inputs.length > 0 ? JSON.stringify(getStepCostsApi.inputs) : 'none';
        const getStepCostsApiOutputs = getStepCostsApi.outputs.length > 0 ? JSON.stringify(getStepCostsApi.outputs) : 'none';
        console.log(`[getStepCosts]\n inputs: ${getStepCostsApiInputs} \n outputs: ${getStepCostsApiOutputs}`);

        // Get step costs by iconService.call
        const callBuilder = new CallBuilder();
        const call = callBuilder
            .to(MockData.GOVERNANCE_ADDRESS)
            .method(methodName)
            .build();
        const stepCosts = this.iconService.call(call).execute();
        // For sending token, it is about twice the default value.
        return IconConverter.toBigNumber(stepCosts.default).times(2)
    }
github icon-project / icon-sdk-js / quickstart / example / js / DeployAndTransferTokenExample.js View on Github external
async buildTokenTransaction() {
        const { CallTransactionBuilder } = IconBuilder;

        const walletAddress = this.wallet.getAddress();
        // 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
github icon-project / icon-sdk-js / quickstart / example / js / DeployAndTransferTokenExample.js View on Github external
async buildTokenTransaction() {
        const { CallTransactionBuilder } = IconBuilder;

        const walletAddress = this.wallet.getAddress();
        // 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)
github icon-project / icon-sdk-js / quickstart / example / js / TokenTransactionExample.js View on Github external
buildTokenTransaction() {
        const { Builder } = this.iconService;
        const { CallTransactionBuilder } = Builder;

        const walletAddress = this.wallet.getAddress();
        // 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)