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-node in the background. If you omit --url, Pop CLI prompts you to choose a chain endpoint and defaults to ws://127.0.0.1:9944. If that endpoint is not running, Pop CLI offers to start a local ink-node (and Ethereum RPC) in the background. Use --skip-confirm to auto-select the local endpoint and auto-start the node when needed.
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--value: balance transferred to the contract (default:0)--execute: deploys the contract (otherwise Pop CLI runs a dry run)--suri: secret key URI (default://Alice)No
--url: defaults to the local endpoint and can start a local ink-node if needed--use-wallet: sign with a browser wallet (conflicts with--suri)--upload-only: upload without instantiating--gasand--proof-size: override the dry-run estimate (must be provided together)--skip-build: skip building (Pop CLI still builds if artifacts are missing)--skip-confirm: skip prompts and auto-start a local ink-node if needed
If at anytime you need to stop the node you can do the following:
Find the process ID by running the following command:
lsof -i :9944Kill the process by running the
killcommand and passing in the ID of the process:
kill -9 3537
Tip: Use
pop up ink-node --detachto keep a local node running and follow the printedkill -9command to shut it down.
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.
JSON mode
Use global --json for structured deployment output:
JSON mode constraints for contract deployment:
--executeis required.--use-walletis not supported (provide--suri).--upload-onlyis not supported.
Gas
Pop CLI performs a dry run to estimate gas before deployment. If you do not pass --execute, Pop CLI keeps the dry run result and prompts you before deploying. 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 unless you confirm or pass --execute.
You can now see the estimate and make sure your account is properly funded with that amount.
To override the estimate, provide both --gas and --proof-size:
It is also possible to only upload the contract and not instantiate by adding
--upload-only. More on this check out the ink! docs.
Need help?
Ask on Polkadot Stack Exchange (tag it pop) or drop by our Telegram. We're here to help!
Last updated