0

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(),
        }
    }
3
  • Your constructor takes Balance as an arg, not a boolean. What about passing some initial value for e.g. -a 1000000?
    – Shunsuke
    Apr 24 at 6:39
  • @Shunsuke Thank you so much. The error has been gone. Apr 24 at 6:41
  • Please provide the answer to your question or close it. Apr 24 at 7:20

1 Answer 1

3

Constructor takes Balance instead of boolean. So, you need to pass some Balance value via swanky command. E.g. swanky contract deploy erc20 --account alice -g 10000000000 -a 10000000

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.