We can now use the configuration file to spin up the network.
pop up parachain -f ./network.toml
┌ Pop CLI : Launch a local network
│
▲ ⚠️ The following binaries required to launch the network cannot be found locally:
│ > pop-node
│
◇ 📦 Would you like to source them automatically now? It may take some time...
│ > pop-node testnet-v0.4.2
│ Yes
│
▲ ℹ️ The following binaries have newer versions available:
│ > polkadot v1.14.0 -> stable2409, polkadot-parachain v1.14.0 -> stable2409
│
◇ 📦 Would you like to source them automatically now? It may take some time...
│ Yes
│
⚙ ℹ️ Binaries will be cached at /Users/bruno/Library/Caches/pop
│
◇ 📦 Sourcing binaries...
│ ✅ polkadot
│ ✅ pop-node
│ ✅ polkadot-parachain
The first time you run this command it will take some time. Grab some coffee.
Replace the port number with the port number for the Pop Network parachain that is outputted in your terminal
Cool. Now that we have Pop running we can now deploy our contract.
Keep the PolkadotJs App window open, specifically to see the recent events. After we deploy the contract, we will see the events displayed there.
You will need to know the RPC URL for Pop Network which was outputted in the terminal when you ran the pop up command.
pop up contract -p ./flipper --constructor new --args false --suri //Alice --url ws://127.0.0.1:9944
┌ Pop CLI : Deploy a smart contract
│
◐ Doing a dry run to estimate the gas...
● Gas limit Weight { ref_time: 264725731, proof_size: 16689 }
│
◇ Contract deployed and instantiated: The Contract Address is "5CLPm1CeUvJhZ8GCDZCR7nWZ2m3XXe4X5MtAQK69zEjut36A"
│
└ Deployment complete
The contract has been deployed!
Save the contract address as we will be used in the next step to interact with the contract.
You can also confirm that the contract was deployed in the recent events in Polkadot JS:
Interacting with our contract
Now that the contract is live, we can start interacting with it.
Grab the contract address that was outputted from the previous step.
If you lost the address, you can always pull up PolkadotJs Apps and check the chain state for the contract address.
pop call contract -p ./flipper --contract 5CLPm1CeUvJhZ8GCDZCR7nWZ2m3XXe4X5MtAQK69zEjut36A --message get --suri //Alice --url ws://127.0.0.1:4385
┌ Pop CLI : Calling a contract
│
◐ Calling the contract...
⚙ Result: Ok(false)
│
▲ Your call has not been executed.
│
▲ To submit the transaction and execute the call on chain, add -x/--execute flag to the command.
│
└ Call completed successfully!
The result here is false meaning that value in the flipper storage is set to false.
Notice the -x flag at the end of the pop call command. This is needed because we are executing a transaction on the network and it will cost gas.
Did it work? Let's see if the value has been flipped.
pop call contract -p ./flipper --contract 5CLPm1CeUvJhZ8GCDZCR7nWZ2m3XXe4X5MtAQK69zEjut36A --message get --suri //Alice --url ws://127.0.0.1:9944
┌ Pop CLI : Calling a contract
│
◐ Calling the contract...
⚙ Result: Ok(true)
│
▲ Your call has not been executed.
│
▲ To submit the transaction and execute the call on chain, add -x/--execute flag to the command.
│
└ Call completed successfully!
The value is now true.
Awesome we now know how to make calls to our smart contract.