Skip to content

Commit

Permalink
Updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
SKYBITDev3 committed Aug 30, 2023
1 parent 053741e commit 7a466b9
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 4 deletions.
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# SKYBIT Keyless Deployment of Smart Contracts
## Introduction
This tool is for anyone who wants to **deploy smart contracts to the same address** on multiple Ethereum-Virtual-Machine (EVM)-based blockchains. There are many ways to achieve this, but there can be pitfalls depending on which path you take (see the section [Problems that this tool solves](#problems-that-this-tool-solves) for details). It's important to consider your options before you start any deployments to a live blockchain, as it'd be **difficult to switch later** after realizing that you had made a bad decision, especially if many users are already using the contracts that you had deployed.
Expand Down Expand Up @@ -54,8 +55,7 @@ It also makes it possible to:
This repository offers signed raw deployment transactions of unmodified CREATE3 factories from:
- Axelar
- ZeframLou & transmissions11/solmate

More choices may be offered in future.
- SKYBIT & Vectorized/solady

Gas price in the deployment transaction has been set to 100 Gwei = 10<sup>-7</sup> native currency of the blockchain. This is a high value for most blockchains but it's to ensure that the contract will be deployable.

Expand All @@ -82,11 +82,11 @@ Axelar's factory contract will be deployed to this address (if the transaction d
#### ZeframLou & transmissions11/solmate
ZeframLou's factory was included because it's well-known, as is the solmate CREATE3 library that it imports.

The original solidity files were obtained by firstly adding the specific github repository commits:
The original solidity files were obtained by firstly adding the specific github repository commits to `package.json`:
- https://github.com/ZeframLou/create3-factory#18cfad8d118b25a5092cdfed6bea9c932ca5b6eb
- https://github.com/transmissions11/solmate#f2833c7cc951c50e0b5fd7e505571fddc10c8f77

`@ZeframLou/create3-factory/src/CREATE3Factory.sol` is imported in `contracts/Imports.sol`. The `solmate/utils` directory is copied from `node_modules` to the repository root so that compilation would run without needing to change the line `import {CREATE3} from "solmate/utils/CREATE3.sol";` in the original factory contract. Hardhat then compiles it and places the artifacts in `artifacts` directory. `CREATE3Factory.json` was then copied to `artifacts-saved/@ZeframLou/create3-factory/src/CREATE3Factory.sol/CREATE3Factory.json/` directory for preservation.
`@ZeframLou/create3-factory/src/CREATE3Factory.sol` is imported in `contracts/Imports.sol`. The `solmate/utils` directory is copied from `node_modules` to the repository root so that compilation would run without needing to change the line `import {CREATE3} from "solmate/utils/CREATE3.sol";` in the original factory contract. Hardhat then compiles it and places the artifacts in `artifacts` directory. `CREATE3Factory.json` was then copied to `artifacts-saved/@ZeframLou/create3-factory/src/CREATE3Factory.sol/` directory for preservation.

Gas used for the deployment is 394,439 (or a little more for some blockchains), so gas limit in this deployment transaction has been set to 500,000, giving some room in case some opcode costs increase in future, hence there should be at least 0.05 of native currency at the signer's address before factory deployment.

Expand All @@ -95,6 +95,19 @@ ZeframLou's factory contract will be deployed to this address (if the transactio
0xb3cBfCf8ad9eeccE068D8704C9316f38F6cC54b3
```

#### SKYBIT & Vectorized/solady
The Vectorized/solady CREATE3 library has been included because it is gas-efficient. A factory contract is needed to use the library so a new one was created based on ZeframLou's factory.

The original Vectorized/solady CREATE3 solidity file was obtained by firstly adding the specific github repository commit to `package.json`:
https://github.com/Vectorized/solady#03f3fd05fb1da76edc4df83ae6bf32a842c15f12
`contracts\SKYBITCREATE3Factory.sol` imports `{CREATE3} from "@Vectorized/solady/src/utils/CREATE3.sol";`. Hardhat then compiles it and places the artifacts in `artifacts` directory. `SKYBITCREATE3Factory.json` was then copied to `artifacts-saved/contracts/SKYBITCREATE3Factory.sol/` directory for preservation.

Gas used for the deployment is 253,282 (or a little more for some blockchains), so gas limit in this deployment transaction has been set to 400,000, giving some room in case some opcode costs increase in future, hence there should be at least 0.05 of native currency at the signer's address before factory deployment.

The SKYBIT factory contract will be deployed to this address (if the transaction data is unchanged):
```
0x03b2761e6f97b72349686728cb5fF7C565BF7db4
```

### Usage
Other people may have already deployed the factory contract onto some of your desired blockchains to the expected address (if they didn't change the deployment transaction data), in which case you won't need to deploy it on those blockchains - you can then just use those already-deployed factory contracts to deploy whatever other contracts you want to deploy. So first check the expected address on a blockchain explorer to see if a factory contract already exists there.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "SKYBITCREATE3Factory",
"sourceName": "contracts/SKYBITCREATE3Factory.sol",
"abi": [
{
"inputs": [
{
"internalType": "bytes32",
"name": "salt",
"type": "bytes32"
},
{
"internalType": "bytes",
"name": "creationCode",
"type": "bytes"
}
],
"name": "deploy",
"outputs": [
{
"internalType": "address",
"name": "deployed",
"type": "address"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "deployer",
"type": "address"
},
{
"internalType": "bytes32",
"name": "salt",
"type": "bytes32"
}
],
"name": "getDeployed",
"outputs": [
{
"internalType": "address",
"name": "deployed",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
],
"bytecode": "0x608060405234801561001057600080fd5b506103a1806100206000396000f3fe6080604052600436106100295760003560e01c806350f1c4641461002e578063cdcb760a14610077575b600080fd5b34801561003a57600080fd5b5061004e61004936600461021e565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e610085366004610292565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018390526000906054016040516020818303038152906040528051906020012092506100e78383346101a4565b60006040513060005260ff600b53826020527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f6040526055600b20601452806040525061d694600052600160345350506017601e2090565b60006f67363d3d37363d34f03d5260086018f3600052836010806000f5806101d45763301164256000526004601cfd5b8060145261d69460005260016034536017601e20915060008085516020870186855af1610209576319b991a86000526004601cfd5b50803b6100e7576319b991a86000526004601cfd5b6000806040838503121561023157600080fd5b823573ffffffffffffffffffffffffffffffffffffffff8116811461025557600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080604083850312156102a557600080fd5b82359150602083013567ffffffffffffffff808211156102c457600080fd5b818501915085601f8301126102d857600080fd5b8135818111156102ea576102ea610263565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561033057610330610263565b8160405282815288602084870101111561034957600080fd5b826020860160208301376000602084830101528095505050505050925092905056fea2646970667358221220adb8d45e268d3aa3c6c1296cda4c74d7d549bf1d967411a667c87fd2488d9aad64736f6c63430008150033",
"deployedBytecode": "0x6080604052600436106100295760003560e01c806350f1c4641461002e578063cdcb760a14610077575b600080fd5b34801561003a57600080fd5b5061004e61004936600461021e565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e610085366004610292565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018390526000906054016040516020818303038152906040528051906020012092506100e78383346101a4565b60006040513060005260ff600b53826020527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f6040526055600b20601452806040525061d694600052600160345350506017601e2090565b60006f67363d3d37363d34f03d5260086018f3600052836010806000f5806101d45763301164256000526004601cfd5b8060145261d69460005260016034536017601e20915060008085516020870186855af1610209576319b991a86000526004601cfd5b50803b6100e7576319b991a86000526004601cfd5b6000806040838503121561023157600080fd5b823573ffffffffffffffffffffffffffffffffffffffff8116811461025557600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080604083850312156102a557600080fd5b82359150602083013567ffffffffffffffff808211156102c457600080fd5b818501915085601f8301126102d857600080fd5b8135818111156102ea576102ea610263565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561033057610330610263565b8160405282815288602084870101111561034957600080fd5b826020860160208301376000602084830101528095505050505050925092905056fea2646970667358221220adb8d45e268d3aa3c6c1296cda4c74d7d549bf1d967411a667c87fd2488d9aad64736f6c63430008150033",
"linkReferences": {},
"deployedLinkReferences": {}
}
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# yarn lockfile v1


"@Vectorized/solady@https://github.com/Vectorized/solady#03f3fd05fb1da76edc4df83ae6bf32a842c15f12":
version "0.0.105"
resolved "https://github.com/Vectorized/solady#03f3fd05fb1da76edc4df83ae6bf32a842c15f12"

"@ZeframLou/create3-factory@https://github.com/ZeframLou/create3-factory#18cfad8d118b25a5092cdfed6bea9c932ca5b6eb":
version "0.0.0"
resolved "https://github.com/ZeframLou/create3-factory#18cfad8d118b25a5092cdfed6bea9c932ca5b6eb"
Expand Down

0 comments on commit 7a466b9

Please sign in to comment.