githubEdit

Deploy

Now that we have developed our contract, tested it, we can now deploy it on a blockchain!

Local Deployment (default)

If no --url is provided, Pop CLI automatically launches a local ink-nodearrow-up-right in the background.

pop up -p ./path-to-contract \
  --constructor <constructor_name> \
  --args <arg_1> <arg_2> ... \
  --suri //Alice \
  • --path: points to the contract directory

  • --constructor: method name (default: new)

  • --args: constructor arguments

  • --suri: secret key URI (default: //Alice)

  • No --url: spins up ws://localhost:9944 automatically

If at anytime you need to stop the node you can do the following:

  1. Find the process ID by running the following command: lsof -i :9944

  2. Kill the process by running the kill command and passing in the ID of the process:

    • kill -9 3537

When you have successfully deployed your contract you will get the following output:

Save the Contract Address which you will need to interact with the contract.

Deploy to Custom or Public Network

To deploy on a specific network, supply a --url:

Alternatively, use --use-wallet to sign via browser wallet (PolkadotJS, Talisman, SubWallet) instead of exposing private keys.

Gas

When deploying a smart contract you need to know how much gasarrow-up-right is needed so you can pay accordingly. To find an estimate of how much gas you will need, you can do a "dry-run" of the contract:

This will perform a dry-run via an RPC call to estimate the gas usage. It does not submit a transaction.

You can now see the estimate and make sure your account is properly funded with that amount.

It is also possible to only upload the contract and not instantiate by adding --upload-only. More on this check out the ink! docsarrow-up-right.

Need help?

Ask on Polkadot Stack Exchangearrow-up-right (tag it poparrow-up-right) or drop by our Telegramarrow-up-right. We're here to help!

Last updated

Was this helpful?