GitHub Action
Deploy EVM smart contract
Suite of actions to deploy smart contracts using forge.
You can use it to either do a simple contract deployment, or a proxied contract.
You can specify the target EVM to use, and can also trigger the verification of the contract on Etherscan.
The action generates a report of the deployment and verification, then adds the ABI of the contract as an artifact on your action run.
name: Deploy main contract
on:
push:
branches: [ main ]
jobs:
deploy-contract:
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v4
- uses: YBadiss/deploy-contract@v2
with:
contract-name: 'OwnableContractName'
parent-dir: './path/to/contracts'
constructor-args: '${{ vars.OWNER_ADDRESS }}'
deployer-pk: ${{ secrets.DEPLOYER_PK }}
chain-id: '11155111'
rpc-url: ${{ secrets.RPC_ETH_SEPOLIA_HTTPS }}
verify: true
etherscan-url: 'https://sepolia.etherscan.io'
etherscan-api-key: ${{ secrets.ETHERSCAN_SEPOLIA_API_KEY }}
name: Deploy proxied contract
on:
push:
branches: [ main ]
jobs:
deploy-proxied-contract:
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v4
- name: Deploy an implementation and its proxy
uses: YBadiss/deploy-contract/proxy@v2
id: deploy
with:
implementation-contract-name: 'ImplementationContractName'
proxy-contract-name: 'ProxyContractName'
call-args: '"initialize(address)" "${{ vars.OWNER_ADDRESS }}"'
parent-dir: './path/to/contracts'
deployer-pk: ${{ secrets.DEPLOYER_PK }}
chain-id: '11155111'
rpc-url: ${{ secrets.RPC_ETH_SEPOLIA_HTTPS }}
verify: true
etherscan-url: 'https://sepolia.etherscan.io'
etherscan-api-key: ${{ secrets.ETHERSCAN_SEPOLIA_API_KEY }}
- name: Upgrade to a new implementation
uses: YBadiss/deploy-contract/proxy@v2
id: upgrade
with:
implementation-contract-name: 'NewImplementationContractName'
proxy-contract-address: ${{ steps.deploy.outputs.proxy-contract-address }}
call-args: '"doSomething(address,uint) "0x..." 12'
parent-dir: './path/to/contracts'
deployer-pk: ${{ secrets.DEPLOYER_PK }}
chain-id: '11155111'
rpc-url: ${{ secrets.RPC_ETH_SEPOLIA_HTTPS }}
verify: true
etherscan-url: 'https://sepolia.etherscan.io'
etherscan-api-key: ${{ secrets.ETHERSCAN_SEPOLIA_API_KEY }}
- You must have checked out the code using the standard checkout action.
- Installing the latest version of
forge
is performed using the action foundry-toolchain. - Your code must be in a
src
folder, under theparent-dir
input.
Name of the contract to deploy.
Must be the name of the main sol file, and of the target constract class.
REQUIRED
ID of the chain to deploy to. If in doubt see https://chainlist.org/.
REQUIRED
URL of the RPC to use to deploy the contract.
REQUIRED
⚠️ Use github secrets if the URL embeds an API Key.
Private key to use for deployment, in hex format.
REQUIRED
⚠️ Use github secrets.
Parent directory of src
and out
.
OPTIONAL, DEFAULT="."
Arguments to pass to the contract's constructor.
OPTIONAL, DEFAULT=""
Whether to verify the contract or not on Etherscan.
If set to true
, etherscan-url and etherscan-api-key are required.
OPTIONAL, DEFAULT="false"
URL of the etherscan endpoint to use for verification and reporting.
OPTIONAL, DEFAULT=""
API key used for verification.
OPTIONAL, DEFAULT=""
⚠️ Use github secrets.
Address of the newly deployed contract.
Hash of the deployment transaction.
Name of the implementation to deploy.
Must be the name of the main sol file, and of the target constract class.
REQUIRED
Name of the proxy to deploy.
Must be the name of the main sol file, and of the target constract class.
OPTIONAL, DEFAULT=""
Address of the proxy contract.
OPTIONAL, DEFAULT=""
Arguments to initialise the implementation contract with, or pass to upgradeAndCall.
-
In the case of a new deployment, provide the initialiser's function and args.
-
In the case of an upgrade, provide the optional call's function and args.
-
OPTIONAL, DEFAULT=""
Private key to use for deployment, in hex format.
REQUIRED
⚠️ Use github secrets.
Private key to use for changes only the owner can do.
OPTIONAL, DEFAULT=""
⚠️ Use github secrets.
ID of the chain to deploy to. If in doubt see https://chainlist.org/.
REQUIRED
URL of the RPC to use to deploy the contract.
REQUIRED
⚠️ Use github secrets if the URL embeds an API Key.
Parent directory of src
and out
.
OPTIONAL, DEFAULT="."
Whether to verify the contract or not on Etherscan.
If set to true
, etherscan-url and etherscan-api-key are required.
OPTIONAL, DEFAULT="false"
URL of the etherscan endpoint to use for verification and reporting.
OPTIONAL, DEFAULT=""
API key used for verification.
OPTIONAL, DEFAULT=""
⚠️ Use github secrets.
The scripts and documentation in this project are released under the MIT License