A deployment script can help you quickly push your contract to various chains when ready. This lesson covers some deployment basics to make sure any contract you develop will work well on your local blockchain, testnets, and when you're ready, the mainnet.
You may need funded accounts to deploy to testnets and the live blockchain. Storing your accounts into brownie will store the account's sensitive details in a password protected keystore.
Provide Brownie a private key and password for encryption. Your account will be permanently accessible from this id.
> brownie accounts new <id>
Unlock an encrypted account for use in live or testing environments. This account will be added to the Accounts list on success.
> brownie load <id>
When deploying to mainnet you may want to adjust the default gas prices. Some updated functions help with gas after EIP-1559:
Set a tip to be added to the base transaction fee to push your transaction faster.
> from brownie.network import priority_fee
> priority_fee("2 gwei")
Cap the total fee you are willing to pay for your transaction.
> from brownie.network import max_fee
> max_fee("50 gwei")
When your source is published to Etherscan, anybody can review the contract, pull the ABI, and interact directly on Etherscan.
During deployment, verify your source code on Etherscan.
> MyContract.deploy(*args, {'from': your_acct}, publish_source=True)
Create a ContractContainer object from a known deployment address by using any ContractInterface loaded to Brownie.
> contract_object = ContractInterface.at(<address>)
If you failed to publish source at deployment, you can publish retroactively.
> ContractInterface.publish_source(contract_object)