Skip to main content
added 124 characters in body
Source Link

I have written an erc20 smart contract in ink(Rust). The contract has been compiled successfully. But I got an error while deploying my smart contract. Basically, the contract constructor takes total_spply as a parameter. So, how to pass this value while deploying a smart contract using swanky-cli?

This command I am using to deploy smart contract:

swanky contract deploy erc20 --account alice -g 10000000000 -a true

This is my constructor.

  pub fn new(total_supply: Balance) -> Self {
        let mut balances = Mapping::default();
        let caller = Self::env().caller();
        balances.insert(&caller, &total_supply);

        Self::env().emit_event(Transfer {
            from: None,
            to: Some(caller),
            value: total_supply,
        });

        Self {
            total_supply,
            balances,
            allowances: Default::default(),
        }
    }

I have written an erc20 smart contract in ink(Rust). The contract has been compiled successfully. But I got an error while deploying my smart contract. Basically, the contract constructor takes total_spply as a parameter. So, how to pass this value while deploying a smart contract using swanky-cli?

This is my constructor.

  pub fn new(total_supply: Balance) -> Self {
        let mut balances = Mapping::default();
        let caller = Self::env().caller();
        balances.insert(&caller, &total_supply);

        Self::env().emit_event(Transfer {
            from: None,
            to: Some(caller),
            value: total_supply,
        });

        Self {
            total_supply,
            balances,
            allowances: Default::default(),
        }
    }

I have written an erc20 smart contract in ink(Rust). The contract has been compiled successfully. But I got an error while deploying my smart contract. Basically, the contract constructor takes total_spply as a parameter. So, how to pass this value while deploying a smart contract using swanky-cli?

This command I am using to deploy smart contract:

swanky contract deploy erc20 --account alice -g 10000000000 -a true

This is my constructor.

  pub fn new(total_supply: Balance) -> Self {
        let mut balances = Mapping::default();
        let caller = Self::env().caller();
        balances.insert(&caller, &total_supply);

        Self::env().emit_event(Transfer {
            from: None,
            to: Some(caller),
            value: total_supply,
        });

        Self {
            total_supply,
            balances,
            allowances: Default::default(),
        }
    }
Source Link

How to deploy smart contract in ink which constructor takes value in params

I have written an erc20 smart contract in ink(Rust). The contract has been compiled successfully. But I got an error while deploying my smart contract. Basically, the contract constructor takes total_spply as a parameter. So, how to pass this value while deploying a smart contract using swanky-cli?

This is my constructor.

  pub fn new(total_supply: Balance) -> Self {
        let mut balances = Mapping::default();
        let caller = Self::env().caller();
        balances.insert(&caller, &total_supply);

        Self::env().emit_event(Transfer {
            from: None,
            to: Some(caller),
            value: total_supply,
        });

        Self {
            total_supply,
            balances,
            allowances: Default::default(),
        }
    }