Contract Deployment
Arbitrum supports standard EVM contract deployment. This allows standard Solidity smart contracts to be deployed on Arbitrum Chains using existing developer tools.
To deploy your contracts, you need to set your deployment tool to deploy on an Arbitrum rollup chain instead of Ethereum. While this should be straightforward, we include instructions for some build systems here, and we will add to the list over time. If you're using a build system that's not listed here and having trouble configuring it, please reach out to us on Discord.
Hardhat
To port an existing hardhat configuring, simply include the Arbitrum RPC url in hardhat.config.ts
:
module.exports = {
solidity: '0.7.3',
networks: {
arbitrum: {
url: 'https://rinkeby.arbitrum.io/rpc',
},
},
}
See Pet Shop Demo.
Truffle
To port an existing truffle configuration:
First add the
arb-ethers-web3-bridge
to your project:yarn add --dev arb-ethers-web3-bridge
Edit the
truffle-config.js
:- Set the mnemonic and the url to an Arbitrum aggregator at the top of the file.
const HDWalletProvider = require('@truffle/hdwallet-provider') const mnemonic = 'jar deny prosper gasp flush glass core corn alarm treat leg smart' const arbProviderUrl = 'http://localhost:8547/'
- Add the
arbitrum
network tomodule.exports
:
module.exports = { arbitrum: { provider: function () { return new HDWalletProvider(mnemonic, arbProviderUrl) ) }, network_id: '*', }, }, }
Now that the truffle project is set up correctly, just run migrate to deploy your contracts
truffle migrate --reset --network arbitrum
For older versions of truffle (< 0.5.x), do the following:
- Import
wrapProvider
fromarb-ethers-web3-bridge
at the top oftruffle-config.js
:
const wrapProvider = require('arb-ethers-web3-bridge').wrapProvider
- return the wrapped provider here:
module.exports = { arbitrum: { provider: function () { // return wrapped provider: return wrapProvider( new HDWalletProvider(mnemonic, arbProviderUrl) ) }, network_id: '*', }, }, }