=nil; CLI: deploying a smart contract
Overview
This tutorial deploys two smart contracts:
Retailer.sol
: this contract can call a special 'manufacturer' contract and order new products by performing an async call.Manufacturer.sol
: this contract can accept orders from the retailer and fulfil them by 'manufacturing' and sending new products.
Internal deployment
To deploy the retailer via the =nil; CLI:
nil smart-account deploy path/to/Retailer.bin --abi path/to/Retailer.abi --salt SALT
Take note of the address for the retailer. To retrieve the smart account public key:
nil smart-account info
To deploy the manufactuer with the given public key and the address of the retailer contract:
nil smart-account deploy path/to/Manufacturer.bin PUBKEY RETAILER_ADDRESS --abi path/to/Manufacturer.abi --shard-id 2 --salt SALT
This will make sure that Manufacturer.sol
and Retailer.sol
are on different shards.
External deployment
First, calulate the address of the retailer contract and send funds to this address:
nil contract address path/to/Retailer.bin --shard-id 1 --salt SALT
nil smart-account send-tokens RETAILER_ADDRESS AMOUNT
Then, deploy the retailer contract while providing the same SALT
:
nil contract deploy path/to/Retailer.bin --shard-id 1 --salt SALT
Retrieve the public key assigned to the smart account:
nil smart-account info
Calculate the address of the manufacturer contract and send funds to it:
nil contract address path/to/Manufacturer.bin PUBKEY RETAILER_ADDRESS --shard-id 2 --salt SALT --abi path/to/Manufacturer.abi
nil smart-account send-tokens MANUFACTURER_ADDRESS AMOUNT
Deploy the manufacturer contract:
nil contract deploy path/to/Manufacturer.bin PUBKEY RETAILER_ADDRESS --salt SALT --shard-id 2 --abi path/to/Manufacturer.abi