├── based ├── base.jpeg ├── ethereum │ ├── eth-diamond-purple.png │ └── index.md ├── blockchain-basics │ ├── whatisablockchain.png │ └── index.md ├── solidity │ ├── logo.svg │ └── index.md ├── base │ ├── Base_Wordmark_Blue.svg │ └── index.md ├── README.md └── THIRD-PARTY-NOTICES ├── bridge └── native │ ├── prettier.config.js │ ├── secrets.json.sample │ ├── package.json │ ├── abi │ ├── l2ToL1MessagePasser.json │ ├── erc20.json │ ├── l2OutputOracle.json │ ├── optimismPortal.json │ ├── l2standardbridge.json │ └── l1standardbridge.json │ ├── README.md │ └── hardhat.config.js ├── erc └── 6551 │ ├── images │ ├── assets_tab.png │ ├── copy_address.png │ ├── private_keys.png │ ├── select_wallet.png │ ├── testnet_base.png │ ├── enable_testnet.png │ ├── testnet_networks.png │ ├── assets_tab_resize.png │ ├── assets_tab_select.png │ ├── private_keys_show1.png │ ├── testnet_select_tab.png │ ├── copy_address_resize.png │ ├── enable_testnet_resize.png │ ├── enable_testnet_toggle.png │ ├── private_keys_copy2cb.png │ ├── private_keys_resize.png │ ├── select_wallet_resize.png │ ├── testnet_base_request.png │ ├── testnet_base_resize.png │ ├── enable_testnet_settings.png │ ├── testnet_networks_resize.png │ ├── assets_tab_select_resize.png │ ├── private_keys_show1_resize.png │ ├── testnet_select_tab_resize.png │ ├── enable_testnet_toggle_resize.png │ ├── private_keys_copy2cb_resize.png │ ├── testnet_base_request_resize.png │ └── enable_testnet_settings_resize.png │ ├── license-report-config.json │ ├── package.json │ ├── config.js │ ├── contracts │ ├── ERC721Token.sol │ ├── interfaces │ │ ├── IERC6551Registry.sol │ │ └── IERC6551Account.sol │ ├── ERC6551Registry.sol │ ├── ERC6551Account.sol │ └── lib │ │ └── Bytecode.sol │ ├── THIRD-PARTY-NOTICES │ ├── hardhat.config.js │ ├── scripts │ ├── 02_mint_nft.js │ ├── 03_create_account.js │ ├── 01_deploy_contracts.js │ └── 04_account_interaction.js │ ├── storeDeploymentData.js │ ├── test │ └── Token.test.js │ ├── LICENSE │ └── README.md ├── .gitignore ├── reflections-on-building-on-base.md ├── README.md ├── Base_Wordmark_Blue.svg └── LICENSE /based/base.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/based/base.jpeg -------------------------------------------------------------------------------- /bridge/native/prettier.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'singleQuote': true, 3 | }; 4 | -------------------------------------------------------------------------------- /bridge/native/secrets.json.sample: -------------------------------------------------------------------------------- 1 | { 2 | "mnemonic":"my 12 words", 3 | "alchemyKey": "api key" 4 | } -------------------------------------------------------------------------------- /erc/6551/images/assets_tab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/assets_tab.png -------------------------------------------------------------------------------- /erc/6551/images/copy_address.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/copy_address.png -------------------------------------------------------------------------------- /erc/6551/images/private_keys.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/private_keys.png -------------------------------------------------------------------------------- /erc/6551/images/select_wallet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/select_wallet.png -------------------------------------------------------------------------------- /erc/6551/images/testnet_base.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/testnet_base.png -------------------------------------------------------------------------------- /erc/6551/images/enable_testnet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/enable_testnet.png -------------------------------------------------------------------------------- /erc/6551/images/testnet_networks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/testnet_networks.png -------------------------------------------------------------------------------- /based/ethereum/eth-diamond-purple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/based/ethereum/eth-diamond-purple.png -------------------------------------------------------------------------------- /erc/6551/images/assets_tab_resize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/assets_tab_resize.png -------------------------------------------------------------------------------- /erc/6551/images/assets_tab_select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/assets_tab_select.png -------------------------------------------------------------------------------- /erc/6551/images/private_keys_show1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/private_keys_show1.png -------------------------------------------------------------------------------- /erc/6551/images/testnet_select_tab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/testnet_select_tab.png -------------------------------------------------------------------------------- /erc/6551/images/copy_address_resize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/copy_address_resize.png -------------------------------------------------------------------------------- /erc/6551/images/enable_testnet_resize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/enable_testnet_resize.png -------------------------------------------------------------------------------- /erc/6551/images/enable_testnet_toggle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/enable_testnet_toggle.png -------------------------------------------------------------------------------- /erc/6551/images/private_keys_copy2cb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/private_keys_copy2cb.png -------------------------------------------------------------------------------- /erc/6551/images/private_keys_resize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/private_keys_resize.png -------------------------------------------------------------------------------- /erc/6551/images/select_wallet_resize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/select_wallet_resize.png -------------------------------------------------------------------------------- /erc/6551/images/testnet_base_request.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/testnet_base_request.png -------------------------------------------------------------------------------- /erc/6551/images/testnet_base_resize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/testnet_base_resize.png -------------------------------------------------------------------------------- /erc/6551/images/enable_testnet_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/enable_testnet_settings.png -------------------------------------------------------------------------------- /erc/6551/images/testnet_networks_resize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/testnet_networks_resize.png -------------------------------------------------------------------------------- /based/blockchain-basics/whatisablockchain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/based/blockchain-basics/whatisablockchain.png -------------------------------------------------------------------------------- /erc/6551/images/assets_tab_select_resize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/assets_tab_select_resize.png -------------------------------------------------------------------------------- /erc/6551/images/private_keys_show1_resize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/private_keys_show1_resize.png -------------------------------------------------------------------------------- /erc/6551/images/testnet_select_tab_resize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/testnet_select_tab_resize.png -------------------------------------------------------------------------------- /erc/6551/images/enable_testnet_toggle_resize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/enable_testnet_toggle_resize.png -------------------------------------------------------------------------------- /erc/6551/images/private_keys_copy2cb_resize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/private_keys_copy2cb_resize.png -------------------------------------------------------------------------------- /erc/6551/images/testnet_base_request_resize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/testnet_base_request_resize.png -------------------------------------------------------------------------------- /erc/6551/images/enable_testnet_settings_resize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stalim17/guides/HEAD/erc/6551/images/enable_testnet_settings_resize.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | *.swp 4 | *.iml 5 | 6 | .DS_Store 7 | 8 | *.out 9 | *.test 10 | go.work 11 | main 12 | 13 | .env* 14 | 15 | node_modules/ 16 | secrets.json -------------------------------------------------------------------------------- /erc/6551/license-report-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "output": "markdown", 3 | "fields": [ 4 | "name", 5 | "licensePeriod", 6 | "material", 7 | "licenseType", 8 | "link", 9 | "comment", 10 | "installedVersion", 11 | "author" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /bridge/native/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hardhat-project", 3 | "dependencies": { 4 | "@nomicfoundation/hardhat-ethers": "^3.0.4", 5 | "@nomicfoundation/hardhat-toolbox": "^3.0.0", 6 | "ethers": "^6.7.0" 7 | }, 8 | "devDependencies": { 9 | "prettier": "^3.0.3" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /erc/6551/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "erc6551", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "devDependencies": { 12 | "@nomicfoundation/hardhat-toolbox": "^3.0.0", 13 | "dotenv": "^16.3.1", 14 | "hardhat": "^2.17.1" 15 | }, 16 | "dependencies": { 17 | "@openzeppelin/contracts": "^4.9.3" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /based/solidity/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /erc/6551/config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Coinbase Global, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const deploymentFile = 'deploymentData.json'; 18 | 19 | module.exports = { 20 | deploymentFile, 21 | }; 22 | -------------------------------------------------------------------------------- /erc/6551/contracts/ERC721Token.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.19; 4 | 5 | import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; 6 | import "@openzeppelin/contracts/utils/Counters.sol"; 7 | 8 | 9 | 10 | contract Token is ERC721 { 11 | using Counters for Counters.Counter; 12 | Counters.Counter private _tokenIds; 13 | 14 | constructor() ERC721("FocusedFoxes","BFF") {} 15 | 16 | 17 | function mint(address to)public returns(uint256){ 18 | uint256 newTokenId = _tokenIds.current(); 19 | _safeMint(to, newTokenId); 20 | _tokenIds.increment(); 21 | 22 | return newTokenId; 23 | } 24 | 25 | function getTokenIds() public view returns (uint256) { 26 | return _tokenIds.current(); 27 | } 28 | } -------------------------------------------------------------------------------- /erc/6551/contracts/interfaces/IERC6551Registry.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IERC6551Registry { 5 | 6 | event AccountCreated( 7 | address account, 8 | address implementation, 9 | uint256 chainId, 10 | address tokenContract, 11 | uint256 tokenId, 12 | uint256 salt 13 | ); 14 | 15 | function createAccount( 16 | address implementation, 17 | uint256 chainId, 18 | address tokenContract, 19 | uint256 tokenId, 20 | uint256 seed, 21 | bytes calldata initData 22 | ) external returns (address); 23 | 24 | function account( 25 | address implementation, 26 | uint256 chainId, 27 | address tokenContract, 28 | uint256 tokenId, 29 | uint256 salt 30 | ) external view returns (address); 31 | } -------------------------------------------------------------------------------- /erc/6551/contracts/interfaces/IERC6551Account.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IERC6551AccountProxy { 5 | function implementation() external view returns (address); 6 | } 7 | 8 | /// @dev the ERC-165 identifier for this interface is `0xeff4d378` 9 | interface IERC6551Account { 10 | event TransactionExecuted(address indexed target, uint256 indexed value, bytes data); 11 | 12 | receive() external payable; 13 | 14 | function executeCall( 15 | address to, 16 | uint256 value, 17 | bytes calldata data 18 | ) external payable returns (bytes memory); 19 | 20 | function token() 21 | external 22 | view 23 | returns ( 24 | uint256 chainId, 25 | address tokenContract, 26 | uint256 tokenId 27 | ); 28 | 29 | function owner() external view returns (address); 30 | 31 | function nonce() external view returns (uint256); 32 | } -------------------------------------------------------------------------------- /reflections-on-building-on-base.md: -------------------------------------------------------------------------------- 1 | # Thoughts on Building in the Base Ecosystem 2 | 3 | When I first started exploring Base, it wasn’t just another Layer 2 solution to me. 4 | It felt like a chance to participate in something genuinely new — an attempt to make onchain life accessible, fast, and expressive. 5 | 6 | Through these projects, I’ve realized that Base is more than infrastructure. 7 | It’s a place where developers and creators build culture, not just code. 8 | Every repository, every commit, every open issue is part of that shared story. 9 | 10 | I’m sharing this note not as a tutorial, but as a reflection — a small piece of the mindset that keeps people like us building even when no one’s watching. 11 | There’s something deeply rewarding about knowing that what we push today might be the foundation for someone else’s idea tomorrow. 12 | 13 | The Base ecosystem is still early, but its direction is clear: openness, collaboration, and persistence. 14 | If you’re reading this, maybe it’s a reminder that small actions matter — every improvement, every experiment, every line of code adds to the momentum that carries us all forward. 15 | 16 | > We’re not just deploying contracts. 17 | > We’re building continuity. ⚡ 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | # Build On [Base](https://base.org/) 4 | 5 | ## Guides 6 | 7 | These are a set of guides to help build on Base. Looking forward to seeing you onchain. 8 | 9 | Builder Guides 10 | 11 | | Title | Description | 12 | | -------------------------- | ------------------------------------------------------- | 13 | | [Based](./based/README.md) | Learn how Base is built through technical documentation | 14 | 15 | ERC Guides 16 | 17 | | Title | Description | 18 | | ---------------------------- | ----------------------------------- | 19 | | [6551](./erc/6551/README.md) | How to deploy a token bound account | 20 | 21 | Bridge Guides 22 | 23 | | Title | Description | 24 | | ----------------------------------- | ---------------------------- | 25 | | [Native](./bridge/native/README.md) | How to bridge tokens to base | 26 | 27 | ## Troubleshooting 28 | 29 | If you run into any troubles, please reach out for help on the [Base Discord](https://discord.gg/buildonbase) 30 | 31 | ## License 32 | 33 | All files within this repository are licensed under the [Apache 2.0 License](./LICENSE) unless stated otherwise. 34 | -------------------------------------------------------------------------------- /erc/6551/THIRD-PARTY-NOTICES: -------------------------------------------------------------------------------- 1 | | Name | License period | Material not material | License type | Link | Comment | Installed version | Author | 2 | | :------------------------------- | :------------- | :-------------------- | :----------- | :------------------------------------------------------------- | :------ | :---------------- | :---------------------------------------------------- | 3 | | @openzeppelin/contracts | perpetual | material | MIT | git+https://github.com/OpenZeppelin/openzeppelin-contracts.git | 4.9.3 | 4.9.2 | OpenZeppelin Community | 4 | | @nomicfoundation/hardhat-toolbox | perpetual | material | MIT | git+https://github.com/nomicfoundation/hardhat.git | 3.0.0 | 3.0.0 | Nomic Foundation | 5 | | dotenv | perpetual | material | BSD-2-Clause | git://github.com/motdotla/dotenv.git | 16.3.1 | 16.3.1 | n/a | 6 | | hardhat | perpetual | material | MIT | git+https://github.com/nomiclabs/hardhat.git | 2.17.1 | 2.17.0 | Nomic Labs LLC | 7 | -------------------------------------------------------------------------------- /erc/6551/hardhat.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Coinbase Global, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | require('@nomicfoundation/hardhat-toolbox'); 18 | require('dotenv').config(); 19 | 20 | /** @type import('hardhat/config').HardhatUserConfig */ 21 | module.exports = { 22 | solidity: { 23 | version: '0.8.19', 24 | }, 25 | networks: { 26 | // for mainnet 27 | 'base-mainnet': { 28 | url: 'https://developer-access-mainnet.base.org', 29 | accounts: [process.env.WALLET_KEY, process.env.WALLET2_KEY], 30 | chainId: 8453, 31 | }, 32 | // for testnet 33 | 'base-goerli': { 34 | url: 'https://goerli.base.org', 35 | accounts: [process.env.WALLET_KEY, process.env.WALLET2_KEY], 36 | chainId: 84531, 37 | gasPrice: 'auto', 38 | }, 39 | // for local dev environment 40 | 'base-local': { 41 | url: 'http://127.0.0.1:8545/', 42 | accounts: [process.env.WALLET_KEY, process.env.WALLET2_KEY], 43 | chainId: 31337, 44 | gasPrice: 'auto', 45 | }, 46 | }, 47 | defaultNetwork: 'base-local', 48 | }; 49 | -------------------------------------------------------------------------------- /erc/6551/scripts/02_mint_nft.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Coinbase Global, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const hre = require('hardhat'); 18 | const fs = require('fs'); 19 | const { deploymentFile } = require('../config'); 20 | const storeDeploymentData = require('../storeDeploymentData'); 21 | const deploymentData = fs.readFileSync(deploymentFile, 'utf-8'); 22 | const contracts = JSON.parse(deploymentData); 23 | const wallet2 = process.env.WALLET2_ADDR; 24 | const contractAddress = contracts[0].NftContract.address; 25 | 26 | async function mint() { 27 | console.log(contractAddress); 28 | const ERC721Contract = await hre.ethers.getContractAt( 29 | 'Token', 30 | contractAddress 31 | ); 32 | console.log('Minting NFT...'); 33 | await ERC721Contract.mint(wallet2); 34 | const tokenId = Number(await ERC721Contract.getTokenIds()) - 1; 35 | const owner = await ERC721Contract.ownerOf(tokenId); 36 | console.log(`TokenId ${tokenId} is owned by address: ${owner}`); 37 | } 38 | 39 | mint().catch((error) => { 40 | console.log(error); 41 | process.exitCode = 1; 42 | }); 43 | -------------------------------------------------------------------------------- /erc/6551/storeDeploymentData.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Coinbase Global, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const fs = require('fs'); 18 | function storeDeploymentData( 19 | contractName, 20 | contractAddress, 21 | deployer, 22 | deploymentHash, 23 | deploymentFile 24 | ) { 25 | const deploymentData = { 26 | [contractName]: { 27 | address: contractAddress, 28 | deployer: deployer, 29 | deploymentHash: deploymentHash, 30 | }, 31 | }; 32 | 33 | if (!fs.existsSync(deploymentFile)) { 34 | fs.closeSync(fs.openSync(deploymentFile, 'w')); 35 | } 36 | 37 | const file = fs.readFileSync(deploymentFile); 38 | 39 | if (file.length == 0) { 40 | fs.writeFileSync(deploymentFile, JSON.stringify([deploymentData])); 41 | console.log(`Saved deployment data to a new file: ${deploymentFile}`); 42 | } else { 43 | const json = JSON.parse(file.toString()); 44 | json.push(deploymentData); 45 | console.log(json); 46 | fs.writeFileSync(deploymentFile, JSON.stringify(json)); 47 | console.log(`Deployment data saved to: ${deploymentFile}`); 48 | } 49 | } 50 | 51 | module.exports = storeDeploymentData; 52 | -------------------------------------------------------------------------------- /Base_Wordmark_Blue.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /based/base/Base_Wordmark_Blue.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /erc/6551/scripts/03_create_account.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Coinbase Global, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const hre = require('hardhat'); 18 | const fs = require('fs'); 19 | const { deploymentFile } = require('../config'); 20 | const deploymentData = fs.readFileSync(deploymentFile, 'utf-8'); 21 | const contracts = JSON.parse(deploymentData); 22 | 23 | const nftContract = contracts[0].NftContract.address; 24 | const registryContract = contracts[1].ERC6551Registry.address; 25 | const accountImplementation = contracts[2].ERC6551Account.address; 26 | 27 | async function setupAccount() { 28 | const chainId = (await hre.ethers.provider.getNetwork()).chainId; 29 | const ERC6551Registry = await hre.ethers.getContractAt( 30 | 'ERC6551Registry', 31 | registryContract 32 | ); 33 | const computedAddress = await ERC6551Registry.account( 34 | accountImplementation, //implementation address 35 | chainId, 36 | nftContract, 37 | 0, //tokenId 38 | 0 //salt 39 | ); 40 | console.log('Computed Address: ', computedAddress); 41 | const tx = await ERC6551Registry.createAccount( 42 | accountImplementation, 43 | chainId, 44 | nftContract, 45 | 0, 46 | 0, 47 | '0x' // initData 48 | ); 49 | } 50 | 51 | setupAccount(); 52 | -------------------------------------------------------------------------------- /based/README.md: -------------------------------------------------------------------------------- 1 | # all your base are belong to you. 2 | 3 |

4 | 5 | This guide is intended to act as a tour of the Base ecosystem in order to help 6 | with technical ramping to the protocol. It is intended to be a crash course moving 7 | through major topics, providing links to articles and tutorials to help filter out 8 | the significant amount of noise one encounters when trying to learn how blockchain 9 | works for the first time. This is not exhaustive, but many of the resources 10 | referenced within the guide have additional content in their portals to go deeper 11 | once you have a functional understanding. All resources are free to access, and 12 | all time estimates are ScientificWildAssGuesses (SWAG). 13 | 14 | The guide is intended to be read in the following order (but feel free to jump around as you see fit): 15 | 16 | | Article | Description | 17 | | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | 18 | | [Blockchain Basics](blockchain-basics/index.md) | Background material that will help with understanding how blockchains work | 19 | | [Ethereum](ethereum/index.md) | Ethereum is the Layer 1 that Base is built on, and understanding how it works is critical | 20 | | [Smart Contracts and Solidity](solidity/index.md) | Smart contracts let us codify onchain contracts and transactions, with Solidity being the most popular language they're written in | 21 | | [Base](base/index.md) | Learn how Base was built on top of the Bedrock OP Stack | 22 | -------------------------------------------------------------------------------- /erc/6551/contracts/ERC6551Registry.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | 4 | pragma solidity ^0.8.19; 5 | 6 | import "@openzeppelin/contracts/utils/Create2.sol"; 7 | import "./interfaces/IERC6551Registry.sol"; 8 | 9 | contract ERC6551Registry is IERC6551Registry { 10 | error InitializationFailed(); 11 | //emit event 12 | 13 | 14 | function createAccount( 15 | address implementation, 16 | uint256 chainId, 17 | address tokenContract, 18 | uint256 tokenId, 19 | uint256 salt, 20 | bytes calldata initData 21 | ) external returns (address) { 22 | bytes memory code = _creationCode(implementation, chainId, tokenContract, tokenId, salt); 23 | 24 | address _account = Create2.computeAddress( 25 | bytes32(salt), 26 | keccak256(code) 27 | ); 28 | 29 | if (_account.code.length != 0) return _account; 30 | 31 | _account = Create2.deploy(0, bytes32(salt), code); 32 | 33 | if (initData.length != 0) { 34 | (bool success, ) = _account.call(initData); 35 | if (!success) revert InitializationFailed(); 36 | } 37 | 38 | emit AccountCreated( 39 | _account, 40 | implementation, 41 | chainId, 42 | tokenContract, 43 | tokenId, 44 | salt 45 | ); 46 | 47 | return _account; 48 | } 49 | 50 | function account( 51 | address implementation, 52 | uint256 chainId, 53 | address tokenContract, 54 | uint256 tokenId, 55 | uint256 salt 56 | ) external view returns (address) { 57 | bytes32 bytecodeHash = keccak256( 58 | _creationCode(implementation, chainId, tokenContract, tokenId, salt) 59 | ); 60 | 61 | return Create2.computeAddress(bytes32(salt), bytecodeHash); 62 | } 63 | 64 | function _creationCode( 65 | address implementation_, 66 | uint256 chainId_, 67 | address tokenContract_, 68 | uint256 tokenId_, 69 | uint256 salt_ 70 | ) internal pure returns (bytes memory) { 71 | return 72 | abi.encodePacked( 73 | hex"3d60ad80600a3d3981f3363d3d373d3d3d363d73", 74 | implementation_, 75 | hex"5af43d82803e903d91602b57fd5bf3", 76 | abi.encode(salt_, chainId_, tokenContract_, tokenId_) 77 | ); 78 | } 79 | } -------------------------------------------------------------------------------- /erc/6551/scripts/01_deploy_contracts.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Coinbase Global, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const hre = require('hardhat'); 18 | const { deploymentFile } = require('../config'); 19 | const storeDeploymentData = require('../storeDeploymentData'); 20 | 21 | const wallet2 = process.env.WALLET2_ADDR; 22 | async function deploy() { 23 | const provider = new hre.ethers.JsonRpcProvider('http://127.0.0.1:8545/'); 24 | const signer = new hre.ethers.Wallet(process.env.WALLET_KEY, provider); 25 | 26 | const ERC721Contract = await hre.ethers.deployContract('Token'); 27 | await ERC721Contract.waitForDeployment(); 28 | const ERC721ContractAddress = ERC721Contract.target; 29 | console.log(`ERC-721 Contract deployed at: ${ERC721ContractAddress}`); 30 | const ERC721DeploymentHash = ERC721Contract.deploymentTransaction().hash; 31 | storeDeploymentData( 32 | 'NftContract', 33 | ERC721ContractAddress, 34 | signer.address, 35 | ERC721DeploymentHash, 36 | deploymentFile 37 | ); 38 | 39 | const Registry = await hre.ethers.deployContract('ERC6551Registry'); 40 | await Registry.waitForDeployment(); 41 | const RegistryAddress = Registry.target; 42 | console.log(`Deployed registry contract at: ${RegistryAddress}`); 43 | const RegistryDeploymentHash = Registry.deploymentTransaction().hash; 44 | storeDeploymentData( 45 | 'ERC6551Registry', 46 | RegistryAddress, 47 | signer.address, 48 | RegistryDeploymentHash, 49 | deploymentFile 50 | ); 51 | 52 | console.log('Deploying Token Bound Account'); 53 | const ERC6551Account = await hre.ethers.deployContract('ERC6551Account'); 54 | await ERC6551Account.waitForDeployment(); 55 | const ERC6551AccountAddress = ERC6551Account.target; 56 | const ERC6551ContractDeploymentHash = 57 | ERC6551Account.deploymentTransaction().hash; 58 | console.log(`Token bound account deployed at: ${ERC6551Account.target}`); 59 | storeDeploymentData( 60 | 'ERC6551Account', 61 | ERC6551AccountAddress, 62 | signer.address, 63 | ERC6551ContractDeploymentHash, 64 | deploymentFile 65 | ); 66 | } 67 | 68 | deploy().catch((error) => { 69 | console.log(error); 70 | process.exitCode = 1; 71 | }); 72 | -------------------------------------------------------------------------------- /erc/6551/contracts/ERC6551Account.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.19; 3 | 4 | import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; 5 | import "@openzeppelin/contracts/interfaces/IERC1271.sol"; 6 | import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; 7 | import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol"; 8 | import "./interfaces/IERC6551Account.sol"; 9 | import "./lib/Bytecode.sol"; 10 | 11 | contract ERC6551Account is IERC165, IERC1271, IERC6551Account { 12 | receive() external payable {} 13 | 14 | function executeCall( 15 | address to, 16 | uint256 value, 17 | bytes calldata data 18 | ) external payable returns (bytes memory result) { 19 | require(msg.sender == owner(), "Not token owner"); 20 | 21 | bool success; 22 | (success, result) = to.call{value: value}(data); 23 | 24 | if (!success) { 25 | assembly { 26 | revert(add(result, 32), mload(result)) 27 | } 28 | } 29 | } 30 | 31 | function token() 32 | external 33 | view 34 | returns (uint256 chainId, address tokenContract, uint256 tokenId) 35 | { 36 | uint256 length = address(this).code.length; 37 | return 38 | abi.decode( 39 | Bytecode.codeAt(address(this), length - 0x60, length), 40 | (uint256, address, uint256) 41 | ); 42 | } 43 | 44 | function owner() public view returns (address) { 45 | (uint256 chainId, address tokenContract, uint256 tokenId) = this 46 | .token(); 47 | if (chainId != block.chainid) return address(0); 48 | 49 | return IERC721(tokenContract).ownerOf(tokenId); 50 | } 51 | 52 | function supportsInterface(bytes4 interfaceId) public pure returns (bool) { 53 | return (interfaceId == type(IERC165).interfaceId || 54 | interfaceId == type(IERC6551Account).interfaceId); 55 | } 56 | 57 | function isValidSignature( 58 | bytes32 hash, 59 | bytes memory signature 60 | ) external view returns (bytes4 magicValue) { 61 | bool isValid = SignatureChecker.isValidSignatureNow( 62 | owner(), 63 | hash, 64 | signature 65 | ); 66 | 67 | if (isValid) { 68 | return IERC1271.isValidSignature.selector; 69 | } 70 | 71 | return ""; 72 | } 73 | 74 | function nonce() external view override returns (uint256) {} 75 | 76 | function send(address payable to, uint256 amount) external payable{ 77 | require(msg.sender == owner(), "Not token owner"); 78 | require(address(this).balance >= amount, "Insufficient funds"); 79 | to.transfer(amount); 80 | } 81 | } -------------------------------------------------------------------------------- /based/blockchain-basics/index.md: -------------------------------------------------------------------------------- 1 | ### [Home](../README.md) | [Next](../ethereum/index.md) 2 | 3 | # Blockchain Basics 4 | 5 |

6 | 7 | Blockchains are complex. The technology that makes them work is a result of 8 | decades of innovation across several disciplines. To understand how we got to 9 | where we are today, there needs to be some basic understanding of the 10 | underlying concepts. These articles are meant to be a relatively high level 11 | overview of the core concepts, and most are part of larger hubs of articles in 12 | the event you need to dive deeper into a specific topic. 13 | 14 | Geeks for Geeks has a few sets of articles that are good starting points. This 15 | will give a background in how to understand the way blockchain tech works. Learn 16 | [a basic understanding of computer networking](https://www.geeksforgeeks.org/basics-computer-networking/#) (30 min) 17 | 18 | This full hub of articles is worth going through at some point. The goal for now 19 | is to just learn some of the common terminology and reading the main intro 20 | article is sufficient. Everything on the blockchain is handled through 21 | networking distributed nodes, and having some understanding of computer 22 | networking is essential. 23 | 24 | [What is Peer to Peer Process](https://www.geeksforgeeks.org/what-is-p2p-peer-to-peer-process/) (20 min) 25 | 26 | The specific type of network that a blockchain runs on is Peer to Peer. This is 27 | from the blockchain knowledge series on Geeks for Geeks, which again is worth 28 | diving into fully at some point. 29 | 30 | [Blockchain Cryptography](https://www.geeksforgeeks.org/cryptography-in-blockchain/) (20 min) 31 | 32 | Blockchain networks only function through effective cryptography. The use of asymmetric keys and hashing is a core concept and referred to frequently throughout the Ethereum and Base documentation. 33 | 34 | (Optional) [Tree Data structure](https://www.geeksforgeeks.org/introduction-to-tree-data-structure-and-algorithm-tutorials) 35 | (30 min+) 36 | 37 | The core data structures used to store the blockchain data is built on types of tree data structures called tries. This is helpful from a deeper Computer Science background, but is not necessary to go deeper. 38 | 39 | [What is Blockchain Technology?](https://www.coindesk.com/learn/what-is-blockchain-technology/) (5 min) 40 | 41 | This is a very high-level overview of blockchain as a concept. It helps pull together some of the things mentioned in the above fundamentals. 42 | 43 | Finally a worthwhile read is the [Bitcoin whitepaper](https://bitcoin.org/bitcoin.pdf) (30 min). 44 | Bitcoin was the first cryptocurrency to launch as a functioning, decentralized blockchain. This article is significant as nothing that we are working towards now with Base would exist without Bitcoin. 45 | -------------------------------------------------------------------------------- /erc/6551/contracts/lib/Bytecode.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.19; 3 | 4 | 5 | library Bytecode { 6 | error InvalidCodeAtRange(uint256 _size, uint256 _start, uint256 _end); 7 | 8 | /** 9 | @notice Generate a creation code that results on a contract with `_code` as bytecode 10 | @param _code The returning value of the resulting `creationCode` 11 | @return creationCode (constructor) for new contract 12 | */ 13 | function creationCodeFor(bytes memory _code) internal pure returns (bytes memory) { 14 | /* 15 | 0x00 0x63 0x63XXXXXX PUSH4 _code.length size 16 | 0x01 0x80 0x80 DUP1 size size 17 | 0x02 0x60 0x600e PUSH1 14 14 size size 18 | 0x03 0x60 0x6000 PUSH1 00 0 14 size size 19 | 0x04 0x39 0x39 CODECOPY size 20 | 0x05 0x60 0x6000 PUSH1 00 0 size 21 | 0x06 0xf3 0xf3 RETURN 22 | 23 | */ 24 | 25 | return abi.encodePacked( 26 | hex"63", 27 | uint32(_code.length), 28 | hex"80_60_0E_60_00_39_60_00_F3", 29 | _code 30 | ); 31 | } 32 | 33 | /** 34 | @notice Returns the size of the code on a given address 35 | @param _addr Address that may or may not contain code 36 | @return size of the code on the given `_addr` 37 | */ 38 | function codeSize(address _addr) internal view returns (uint256 size) { 39 | assembly { size := extcodesize(_addr) } 40 | } 41 | 42 | /** 43 | @notice Returns the code of a given address 44 | @dev It will fail if `_end < _start` 45 | @param _addr Address that may or may not contain code 46 | @param _start number of bytes of code to skip on read 47 | @param _end index before which to end extraction 48 | @return oCode read from `_addr` deployed bytecode 49 | 50 | Forked from: https://gist.github.com/KardanovIR/fe98661df9338c842b4a30306d507fbd 51 | */ 52 | function codeAt(address _addr, uint256 _start, uint256 _end) internal view returns (bytes memory oCode) { 53 | uint256 csize = codeSize(_addr); 54 | if (csize == 0) return bytes(""); 55 | 56 | if (_start > csize) return bytes(""); 57 | if (_end < _start) revert InvalidCodeAtRange(csize, _start, _end); 58 | 59 | unchecked { 60 | uint256 reqSize = _end - _start; 61 | uint256 maxSize = csize - _start; 62 | 63 | uint256 size = maxSize < reqSize ? maxSize : reqSize; 64 | 65 | assembly { 66 | // allocate output byte array - this could also be done without assembly 67 | // by using o_code = new bytes(size) 68 | oCode := mload(0x40) 69 | // new "memory end" including padding 70 | mstore(0x40, add(oCode, and(add(add(size, 0x20), 0x1f), not(0x1f)))) 71 | // store length in memory 72 | mstore(oCode, size) 73 | // actually retrieve the code, this needs assembly 74 | extcodecopy(_addr, add(oCode, 0x20), _start, size) 75 | } 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /erc/6551/scripts/04_account_interaction.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Coinbase Global, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const hre = require('hardhat'); 18 | const fs = require('fs'); 19 | const { deploymentFile } = require('../config'); 20 | const deploymentData = fs.readFileSync(deploymentFile, 'utf-8'); 21 | const contracts = JSON.parse(deploymentData); 22 | 23 | const nftContract = contracts[0].NftContract.address; 24 | const registryContract = contracts[1].ERC6551Registry.address; 25 | const accountImplementation = contracts[2].ERC6551Account.address; 26 | 27 | async function getComputedAddress() { 28 | const chainId = (await hre.ethers.provider.getNetwork()).chainId; 29 | const ERC6551Registry = await hre.ethers.getContractAt( 30 | 'ERC6551Registry', 31 | registryContract 32 | ); 33 | const computedAddress = await ERC6551Registry.account( 34 | accountImplementation, //implementation address 35 | chainId, 36 | nftContract, 37 | 0, //tokenId 38 | 0 //salt 39 | ); 40 | return computedAddress; 41 | } 42 | 43 | async function sendFundsToTokenAccount() { 44 | const computedAddress = await getComputedAddress(); 45 | const balanceBefore = await hre.ethers.provider.getBalance(computedAddress); 46 | console.log(`Token account has ${balanceBefore} ETH`); 47 | 48 | const signer = await hre.ethers.provider.getSigner(0); 49 | const tx = { 50 | to: computedAddress, 51 | value: hre.ethers.parseEther('0.0125'), 52 | }; 53 | 54 | await signer.sendTransaction(tx); 55 | const tokenAccountBalance = Number( 56 | await hre.ethers.provider.getBalance(computedAddress) 57 | ); 58 | console.log(`Token account has ${tokenAccountBalance} ETH`); 59 | } 60 | 61 | async function transferToken() { 62 | const signer1 = await hre.ethers.provider.getSigner(0); 63 | const signer2 = await hre.ethers.provider.getSigner(1); 64 | const ERC721Contract = await hre.ethers.getContractAt('Token', nftContract); 65 | const tokenId = 0; 66 | const currentOwner = await ERC721Contract.ownerOf(tokenId); 67 | console.log(`Current owner of tokenId ${tokenId} is ${currentOwner}`); 68 | const ownerContract = ERC721Contract.connect(signer2); 69 | await ownerContract.transferFrom(signer2.address, signer1.address, tokenId); 70 | const newOwner = await ERC721Contract.ownerOf(tokenId); 71 | console.log(`New owner of tokenId ${tokenId} is ${newOwner}`); 72 | } 73 | 74 | async function main() { 75 | sendFundsToTokenAccount(); 76 | transferToken(); 77 | } 78 | 79 | main(); 80 | -------------------------------------------------------------------------------- /bridge/native/abi/l2ToL1MessagePasser.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, 3 | { 4 | "anonymous": false, 5 | "inputs": [ 6 | { 7 | "indexed": true, 8 | "internalType": "uint256", 9 | "name": "nonce", 10 | "type": "uint256" 11 | }, 12 | { 13 | "indexed": true, 14 | "internalType": "address", 15 | "name": "sender", 16 | "type": "address" 17 | }, 18 | { 19 | "indexed": true, 20 | "internalType": "address", 21 | "name": "target", 22 | "type": "address" 23 | }, 24 | { 25 | "indexed": false, 26 | "internalType": "uint256", 27 | "name": "value", 28 | "type": "uint256" 29 | }, 30 | { 31 | "indexed": false, 32 | "internalType": "uint256", 33 | "name": "gasLimit", 34 | "type": "uint256" 35 | }, 36 | { 37 | "indexed": false, 38 | "internalType": "bytes", 39 | "name": "data", 40 | "type": "bytes" 41 | }, 42 | { 43 | "indexed": false, 44 | "internalType": "bytes32", 45 | "name": "withdrawalHash", 46 | "type": "bytes32" 47 | } 48 | ], 49 | "name": "MessagePassed", 50 | "type": "event" 51 | }, 52 | { 53 | "anonymous": false, 54 | "inputs": [ 55 | { 56 | "indexed": true, 57 | "internalType": "uint256", 58 | "name": "amount", 59 | "type": "uint256" 60 | } 61 | ], 62 | "name": "WithdrawerBalanceBurnt", 63 | "type": "event" 64 | }, 65 | { 66 | "inputs": [], 67 | "name": "MESSAGE_VERSION", 68 | "outputs": [{ "internalType": "uint16", "name": "", "type": "uint16" }], 69 | "stateMutability": "view", 70 | "type": "function" 71 | }, 72 | { 73 | "inputs": [], 74 | "name": "burn", 75 | "outputs": [], 76 | "stateMutability": "nonpayable", 77 | "type": "function" 78 | }, 79 | { 80 | "inputs": [ 81 | { "internalType": "address", "name": "_target", "type": "address" }, 82 | { "internalType": "uint256", "name": "_gasLimit", "type": "uint256" }, 83 | { "internalType": "bytes", "name": "_data", "type": "bytes" } 84 | ], 85 | "name": "initiateWithdrawal", 86 | "outputs": [], 87 | "stateMutability": "payable", 88 | "type": "function" 89 | }, 90 | { 91 | "inputs": [], 92 | "name": "messageNonce", 93 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 94 | "stateMutability": "view", 95 | "type": "function" 96 | }, 97 | { 98 | "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], 99 | "name": "sentMessages", 100 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 101 | "stateMutability": "view", 102 | "type": "function" 103 | }, 104 | { 105 | "inputs": [], 106 | "name": "version", 107 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }], 108 | "stateMutability": "view", 109 | "type": "function" 110 | }, 111 | { "stateMutability": "payable", "type": "receive" } 112 | ] 113 | -------------------------------------------------------------------------------- /bridge/native/README.md: -------------------------------------------------------------------------------- 1 | # Native Bridge Examples 2 | 3 | This repository collects a couple examples of how to call the smart contracts to bridge native ETH and ERC20 tokens to Base 4 | 5 | ## Environment Setup 6 | 7 | **Clone this repo** 8 | 9 | ```bash 10 | git clone https://github.com/base-org/guides 11 | ``` 12 | 13 | **Change to the directory** 14 | 15 | ```bash 16 | cd guides/bridge/native 17 | ``` 18 | 19 | **Install the dependencies:** 20 | 21 | ```bash 22 | npm install 23 | ``` 24 | 25 | ## UI 26 | 27 | This is a simple example using OP SDK to bridge native ETH. 28 | 29 | [Demo](https://op-stack-bridge-example.vercel.app/) 30 | 31 | [Code](https://github.com/wilsoncusack/op-stack-bridge-example) 32 | 33 | ## Hardhat Scripts 34 | 35 | Copy secrets.json.sample to secrets.json 36 | 37 | ``` 38 | cp secrets.json.sample secrets.json 39 | ``` 40 | 41 | Add in your test wallet mnemonic and an alchemy key 42 | 43 | If you are new to alchemy, a quickstart is [available here](https://docs.alchemy.com/docs/alchemy-quickstart-guide) 44 | 45 | To verify the values are correct, check the balance with. 46 | 47 | ``` 48 | npx hardhat balance 49 | ``` 50 | 51 | ### Deposits 52 | 53 | You can bridge ETH. 54 | 55 | ``` 56 | npx hardhat bridge --amount 0.1 57 | ``` 58 | 59 | You can bridge any supported ERC20 token. 60 | 61 | WETH on goerli: 0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6 62 | 63 | WETH on base-goerli: 0x4200000000000000000000000000000000000006 64 | 65 | If you need WETH, you can wrap easily on [uniswap](https://app.uniswap.org/#/swap?chain=goerli) 66 | 67 | Cross-chain token addresses can be found in the [Optimism Token List](https://github.com/ethereum-optimism/ethereum-optimism.github.io) 68 | 69 | You bridge a token with 70 | 71 | ``` 72 | npx hardhat bridgeToken --amount 0.01 --l1token 0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6 --l2token 0x4200000000000000000000000000000000000006 73 | ``` 74 | 75 | ### Withdrawals 76 | 77 | You can fetch existing withdrawals with 78 | 79 | ``` 80 | npx hardhat fetchWithdrawals 81 | ``` 82 | 83 | Withdrawals will have 4 booleans to indicate it's lifecycle. 84 | isReadyToProve, isProven, isReadyToFinalize, and isFinalized 85 | 86 | To initiate a native token withdrawal, start with 87 | 88 | ``` 89 | npx hardhat withdraw --amount 0.01 90 | ``` 91 | 92 | The withdrawal will enter a proposing onchain state. Once the withdrawal is proposed and messaged between layer one, the withdrawal can be verified. 93 | 94 | ``` 95 | npx hardhat proveWithdrawal --tx {your transaction hash from above} 96 | ``` 97 | 98 | Once the transaction is proven, the withdrawal has a holding period until it can be finalized. Currently in testnet, this is 12 seconds. Mainnet is 7 days. 99 | 100 | Lastly, you can finalize the transaction with 101 | 102 | ``` 103 | npx hardhat finalizeWithdrawal --tx {your transaction hash from above} 104 | ``` 105 | 106 | The same flow can be used for ERC20 tokens. Make sure that the token is supported by the bridge by checking the l2 base, base-goerli addresses and l1 ethereum, goerli addresses in the [optimism token list](https://github.com/ethereum-optimism/ethereum-optimism.github.io) 107 | 108 | ``` 109 | npx hardhat withdrawToken --amount 0.01 --token 0x4200000000000000000000000000000000000006 110 | ``` 111 | 112 | ## Add your token to Base 113 | 114 | If you already have an ERC20 on Ethereum and want to bridge to Base, a guide is available [here](https://docs.base.org/tokens/list) 115 | -------------------------------------------------------------------------------- /based/base/index.md: -------------------------------------------------------------------------------- 1 | ### [Home](../README.md) | [Previous](../solidity/index.md) 2 | 3 | # Base 4 | 5 |

6 | 7 | Now that we’ve covered core features of Ethereum as well as how Solidity and 8 | Smart Contract development works, we can dive into learning about Base. To get 9 | started here, read the Guide to Base which provides a well-rounded overview of 10 | the entire protocol. We’ll be breaking down the pieces of this guide so that you 11 | can fully understand how the protocol works. 12 | 13 | ## Layer 2 Networks 14 | 15 | Base is built as a Layer 2 network on top of Ethereum. With the popularity of 16 | Ethereum so high, demand has grown to where transaction speed has gone down and 17 | gas costs have shot up significantly. The solution to scaling Ethereum is using 18 | a Layer 2 blockchain, which is a network that fully functions on its own, but 19 | settles all transactions ultimately to the Ethereum network. Base is a specific 20 | implementation of L2 called an optimistic rollup. To better understand scaling 21 | and optimistic rollups, read the following three articles by Ethereum Foundation: 22 | 23 | | Title | Description | 24 | | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | 25 | | [Scaling](https://ethereum.org/en/developers/docs/scaling/) | How Ethereum has scaling issues and the mechanisms to fix them onchain and offchain (Layer 2 Networks) | 26 | | [Optimistic Rollups](https://ethereum.org/en/developers/docs/scaling/optimistic-rollups/) | How optimistic rollup networks work | 27 | | [Zero Knowledge Rollups](https://ethereum.org/en/developers/docs/scaling/zk-rollups/) | How ZK Proof rollup networks work | 28 | 29 | ## OP Bedrock 30 | 31 | Base is built on top of the Bedrock upgrade to the Optimism (OP) Stack. To 32 | better understand Optimism Bedrock, we’ll need to dive into Optimism’s 33 | documentation. 34 | 35 | | Title | Description | 36 | | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | 37 | | [Design Philosophy](https://community.optimism.io/docs/protocol/1-design-philosophy/) | Overall design philosophy on how Optimism was built with its core tenets | 38 | | [Rollup Protocol](https://community.optimism.io/docs/protocol/2-rollup-protocol/#) | The design of the OP Stack's rollup protocol | 39 | | [Bedrock Explainer](https://community.optimism.io/docs/developers/bedrock/) | How OP Bedrock was designed, covering key information about the Sequencer | 40 | 41 | The [Optimism repo](https://github.com/ethereum-optimism/optimism/blob/65ec61dde94ffa93342728d324fecf474d228e1f/specs/README.md) contains the full Bedrock spec. 42 | 43 | The following articles cover the Bedrock Data Flows: 44 | 45 | | Title | Description | 46 | | ------------------------------------------------------------------------------- | ------------------------------------------ | 47 | | [Transaction Flow](https://community.optimism.io/docs/protocol/txn-flow/) | How transactions flow through the OP Stack | 48 | | [Deposit Flow](https://community.optimism.io/docs/protocol/deposit-flow/) | How deposits work in OP Stack | 49 | | [Withdrawal Flow](https://community.optimism.io/docs/protocol/withdrawal-flow/) | How withdrawals work in OP Stack | 50 | 51 | Base being built on Bedrock makes it a part of the Superchain, a decentralized 52 | network of chains that share bridging, decentralized governance, upgrades, a 53 | communication layer and more. Optimism provides [this explainer](https://stack.optimism.io/docs/understand/explainer/) for their vision of the Superchain. 54 | 55 | ## Base Specific Documentation 56 | 57 | Base has its own [doc site](https://docs.base.org/) which helps to explain the 58 | specifics of what you need to know to build on the chain. Some highlights include: 59 | 60 | | Title | Description | 61 | | ---------------------------------------------------------------- | ------------------------------------------------------------------- | 62 | | [Network Information](https://docs.base.org/network-information) | Network information for configuring developer environment endpoints | 63 | | [Key Contract Addresses](https://docs.base.org/base-contracts) | Addresses of key Smart Contracts deployed from OP Stack code | 64 | | [How Fees Work](https://docs.base.org/fees) | How fees work on the Base network | 65 | 66 | Coinbase published a [Guide to Base](https://www.coinbase.com/cloud/discover/protocol-guides/guide-to-base) 67 | which highlights the core features and benefits of the network. 68 | 69 | All code that's been open sourced related to Base can be found in [this repo](https://github.com/base-org) 70 | -------------------------------------------------------------------------------- /based/ethereum/index.md: -------------------------------------------------------------------------------- 1 | ### [Home](../README.md) | [Previous](../blockchain-basics/index.md) | [Next](../solidity/index.md) 2 | 3 | # Ethereum 4 | 5 |

6 | 7 | Base is a layer 2 (L2) blockchain network built on top of Ethereum. In order to 8 | understand how the L2 rollup works, you need to have a good understanding of how 9 | Ethereum works. 10 | 11 | To start you should read the original [Ethereum whitepaper](https://ethereum.org/en/whitepaper/). A lot of the 12 | technology behind Ethereum has changed since then (most significantly the move 13 | to full Proof of Stake after the merge), but many of the core pieces of Ethereum 14 | as a computational platform are explained here. (1 hour) 15 | 16 | Base Camp (the Base developer guide) has a good [Intro video on Ethereum](https://docs.base.org/base-camp/docs/introduction-to-ethereum/intro-to-ethereum-vid/) (8 min) 17 | 18 | The Ethereum Foundation maintains a set of articles around the core functionality of Ethereum. These are all core readings to understand the protocol. Most of these articles are short and should take roughly 5 - 10 min each. 19 | 20 | | Title | Description | 21 | | ------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | 22 | | [Intro to Ethereum](https://ethereum.org/en/developers/docs/intro-to-ethereum/) | Introduction to the Ethereum Blockchain | 23 | | [Intro to Ether](https://ethereum.org/en/developers/docs/intro-to-ether/) | Introduction to Ether Cryptocurrency | 24 | | [Introduction to Dapps](https://ethereum.org/en/developers/docs/dapps/) | Introduction to Decentralized Applications | 25 | | [Web2 vs Web3](https://ethereum.org/en/developers/docs/web2-vs-web3/) | The differences between Web2 and Web3 | 26 | | [Ethereum Accounts](https://ethereum.org/en/developers/docs/accounts/) | How Accounts work on Ethereum | 27 | | [Transactions](https://ethereum.org/en/developers/docs/transactions/) | What makes an Ethereum Transaction and how they work | 28 | | [Blocks](https://ethereum.org/en/developers/docs/blocks/) | How Ethereum state organizes into Blocks | 29 | | [EVM (skip Opcodes)](https://ethereum.org/en/developers/docs/evm/) | How the Ethereum Virtual Machine powers computation in the protocol | 30 | | [Gas](https://ethereum.org/en/developers/docs/gas/) | How gas is used as fees in the network | 31 | | [Nodes and Clients](https://ethereum.org/en/developers/docs/nodes-and-clients/) | Overview of Ethereum Nodes and the clients used to run them | 32 | | [Client Diversity](https://ethereum.org/en/developers/docs/nodes-and-clients/client-diversity/) | Why there are multiple clients for running Ethereum | 33 | | [Node Architecture](https://ethereum.org/en/developers/docs/nodes-and-clients/node-architecture/) | The software architecture of an Ethereum node between the consensus and execution clients | 34 | | [Networks](https://ethereum.org/en/developers/docs/networks/) | Overview of the different Ethereum networks | 35 | | [Consensus Mechanisms](https://ethereum.org/en/developers/docs/consensus-mechanisms/) | High level overview of how consensus works | 36 | | [Proof of Work](https://ethereum.org/en/developers/docs/consensus-mechanisms/pow/) | Covers how Ethereum consensus worked pre-Merge | 37 | | [Proof of Stake](https://ethereum.org/en/developers/docs/consensus-mechanisms/pos/) | Covers how Ethereum consensus currently works | 38 | | [Standards](https://ethereum.org/en/developers/docs/standards/) | This covers EIPs and how Ethereum upgrades itself as well as the token standards that have been implemented | 39 | 40 | Finish remaining [Introduction to Ethereum](https://docs.base.org/base-camp/docs/introduction-to-ethereum/ethereum-dev-overview-vid) Section on Base Camp 41 | (excluding the Guide to Base) (30 min) 42 | 43 | To understand where Ethereum is headed, [this graphic](https://github.com/dcbuild3r/blockchain-development-guide/blob/main/images/ethereum_roadmap.png) covers all the changes that have happened and are coming to the protocol 44 | -------------------------------------------------------------------------------- /based/solidity/index.md: -------------------------------------------------------------------------------- 1 | ### [Home](../README.md) | [Previous](../ethereum/index.md) | [Next](../base/index.md) 2 | 3 | # Smart Contracts and Solidity 4 | 5 |

6 | 7 | Smart Contracts are coded contracts deployed onto a blockchain network. These 8 | contracts are immutable and transactions executed on a smart contract are 9 | irreversible. Understanding how smart contracts work is key to understanding how 10 | Ethereum and Base work. The most popular language for writing smart contracts is 11 | Solidity, which is a high-level, curly bracket, statically typed language. All of 12 | the guides linked below use Solidity as their language of choice, and the best 13 | reference for the language is the docs portal. Anytime you run into an issue with 14 | Solidity, this is the first place to look for answers. 15 | 16 | [Base Camp](https://docs.base.org/base-camp/docs/introduction-to-solidity/introduction-to-solidity-overview) 17 | (2 hours) provides a good introduction to Solidity development with specific modules for 18 | token development and building with Hardhat, a popular framework for Ethereum 19 | development. You should complete the full set of tutorials before moving forward. 20 | 21 | The Ethereum foundation provides a guide to the ETH Stack. Most of the material 22 | on specific tools are covered in the Base Camp tutorials, so the most important 23 | articles from this are listed below: 24 | 25 | | Title | Description | 26 | | ----------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | 27 | | [Intro to the Stack](https://ethereum.org/en/developers/docs/ethereum-stack/) | High level overview of the Ethereum Stack from the EVM up to End-User Dapps | 28 | | [Smart Contracts](https://ethereum.org/en/developers/docs/smart-contracts/) | Overview of how Smart Contracts work | 29 | | [Smart Contracts Languages](https://ethereum.org/en/developers/docs/smart-contracts/languages/) | Covers the programming languages used to develop Smart Contracts on the EVM | 30 | | [Smart Contract Anatomy](https://ethereum.org/en/developers/docs/smart-contracts/anatomy/) | Describes the technical components within a smart contract including storage, functions, events, etc | 31 | | [Smart Contract Libraries](https://ethereum.org/en/developers/docs/smart-contracts/libraries/) | Explains what Smart Contract libraries are and why they are used | 32 | | [Testing Smart Contracts](https://ethereum.org/en/developers/docs/smart-contracts/testing/) | The why and how with regards to testing a Smart Contract | 33 | | [Decentralized Storage](https://ethereum.org/en/developers/docs/storage/) | How storage works in a decentralized blockchain network | 34 | 35 | There are several long tutorials/bootcamps for learning how to develop with 36 | Solidity and Ethereum beyond Base Camp. Alchemy University is a free 7 week full 37 | bootcamp that starts with building on data structures through various Solidity 38 | development modules. 39 | 40 | [Devpill.me](https://Devpill.me) is a fantastic resource for learning all aspects of 41 | development on blockchains. It covers not only Solidity/Smart Contract 42 | development but also Frontend, Backend and more roles within the blockchain 43 | ecosystem. 44 | 45 | For a fun learning experience of building a game, 46 | [CryptoZombies](https://cryptozombies.io/) teaches how to 47 | build blockchain dapps via simple games. 48 | 49 | Before we move on to learning about Base and Optimistic Rollups, there are a 50 | couple of smart contract patterns you should be familiar with. These are 51 | frequently used for upgradeability onchain. Given that deployed contracts are 52 | immutable, several patterns have been developed to allow for versioning between 53 | different deployed versions of a smart contract. 54 | 55 | | Pattern | EIP | Examples | 56 | | ----------------- | --------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | 57 | | Upgradeable Proxy | [EIP-1967](https://eips.ethereum.org/EIPS/eip-1967) | [Solidity By Example](https://solidity-by-example.org/app/upgradeable-proxy/) | 58 | | Diamond Pattern | [EIP-2535](https://eips.ethereum.org/EIPS/eip-2535) | [Medium Article on Pattern](https://medium.com/@solidity101/exploring-the-diamond-standard-eip-2535-for-advanced-smart-contract-development-c4f19d7d015e) | 59 | 60 | Most if not all smart contract patterns are added to Ethereum through the EIP 61 | process as detailed on their doc site under Standards. Ethereum is always under 62 | development, and new proposals add great features to the blockchain. Because Base 63 | is built on top of Ethereum, these proposals add features that can be 64 | asynchronously integrated onto Base as well. To learn more about how EIPs 65 | propagate to layer 2s, read this article by 66 | 67 | Going forward many of the articles will link to specific smart contracts and 68 | EIPs. If you’re curious on how that works in code, Solidity By Example has many 69 | reference examples, and we’ll be calling out specific ones along with articles 70 | explaining how they work. 71 | -------------------------------------------------------------------------------- /erc/6551/test/Token.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Coinbase Global, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const hre = require('hardhat'); 18 | const { expect, assert } = require('chai'); 19 | require('dotenv').config(); 20 | 21 | describe('Contract deployments', () => { 22 | it('Deploys an ERC721 Token', async () => { 23 | const contract = await hre.ethers.deployContract('Token'); 24 | await contract.waitForDeployment(); 25 | assert.ok(contract.target); 26 | console.log(contract.target); 27 | }); 28 | it('Deploys an ERC6551 Registry', async () => { 29 | const contract = await hre.ethers.deployContract('ERC6551Registry'); 30 | await contract.waitForDeployment(); 31 | assert.ok(contract.target); 32 | console.log(contract.target); 33 | }); 34 | it('Deploys an ERC6551 Account Implementation', async () => { 35 | const contract = await hre.ethers.deployContract('ERC6551Account'); 36 | await contract.waitForDeployment(); 37 | assert.ok(contract.target); 38 | console.log(contract.target); 39 | }); 40 | }); 41 | 42 | describe('ERC721 Ownership', () => { 43 | let nftContract; 44 | let address; 45 | let provider; 46 | let signer; 47 | beforeEach(async () => { 48 | provider = ethers.provider; 49 | signer = await provider.getSigner(0); 50 | address = signer.address; 51 | nftContract = await hre.ethers.deployContract('Token'); 52 | await nftContract.waitForDeployment(); 53 | }); 54 | it('Mints a token to the signer', async () => { 55 | await nftContract.mint(address); 56 | const expected = address; 57 | const actual = await nftContract.ownerOf(0); 58 | assert.equal(actual, expected, 'owner is the signer'); 59 | }); 60 | it('Returns correct token count', async () => { 61 | await nftContract.mint(address); 62 | const actual = Number(await nftContract.getTokenIds()); 63 | const expected = 1; 64 | assert.equal(actual, expected, 'returns correct supply'); 65 | console.log('Total supply: ', actual); 66 | }); 67 | }); 68 | 69 | describe('Registry Contract', () => { 70 | let nftContract; 71 | let registryContract; 72 | let erc6551Implementation; 73 | let provider; 74 | let signer; 75 | let chainId; 76 | beforeEach(async () => { 77 | provider = ethers.provider; 78 | signer = await provider.getSigner(0); 79 | chainId = (await hre.ethers.provider.getNetwork()).chainId; 80 | nftContract = await hre.ethers.deployContract('Token'); 81 | registryContract = await hre.ethers.deployContract('ERC6551Registry'); 82 | erc6551Implementation = await hre.ethers.deployContract('ERC6551Account'); 83 | nftContract.waitForDeployment(); 84 | registryContract.waitForDeployment(); 85 | erc6551Implementation.waitForDeployment(); 86 | }); 87 | it('creates a smart contract account', async () => { 88 | await nftContract.mint(signer.address); 89 | const tokenId = Number(await nftContract.getTokenIds()) - 1; 90 | const computedAddress = await registryContract.account( 91 | erc6551Implementation.target, 92 | chainId, 93 | nftContract.target, 94 | tokenId, 95 | 0 96 | ); 97 | 98 | const tx = await registryContract.createAccount( 99 | erc6551Implementation.target, 100 | chainId, 101 | nftContract.target, 102 | tokenId, 103 | 0, 104 | '0x' 105 | ); 106 | 107 | await tx.wait(1); 108 | assert.ok(ethers.isAddress(computedAddress)); 109 | }); 110 | it('can send and receive ETH', async () => { 111 | await nftContract.mint(signer.address); 112 | const tokenId = Number(await nftContract.getTokenIds()) - 1; 113 | const computedAddress = await registryContract.account( 114 | erc6551Implementation.target, 115 | chainId, 116 | nftContract.target, 117 | tokenId, 118 | 0 119 | ); 120 | await registryContract.createAccount( 121 | erc6551Implementation.target, 122 | chainId, 123 | nftContract.target, 124 | tokenId, 125 | 0, 126 | '0x' 127 | ); 128 | const value = hre.ethers.parseEther('0.0125'); 129 | const balanceBefore = await provider.getBalance(computedAddress); 130 | console.log('Balance before: ', balanceBefore); 131 | await signer.sendTransaction({ to: computedAddress, value: value }); 132 | const balanceAfter = await provider.getBalance(computedAddress); 133 | assert.equal(Number(balanceAfter - value), 0); 134 | }); 135 | }); 136 | 137 | describe('Token bound account access control', () => { 138 | let signer; 139 | let receipient; 140 | let chainId; 141 | let nftContract; 142 | let registryContract; 143 | let erc6551Implementation; 144 | let computedAddress; 145 | let tokenId; 146 | beforeEach(async () => { 147 | signer = await ethers.provider.getSigner(0); 148 | receipient = process.env.WALLET2_ADDR; 149 | chainId = (await hre.ethers.provider.getNetwork()).chainId; 150 | nftContract = await hre.ethers.deployContract('Token'); 151 | registryContract = await hre.ethers.deployContract('ERC6551Registry'); 152 | erc6551Implementation = await hre.ethers.deployContract('ERC6551Account'); 153 | await nftContract.mint(receipient); 154 | tokenId = Number(await nftContract.getTokenIds()) - 1; 155 | await registryContract.createAccount( 156 | erc6551Implementation.target, 157 | chainId, 158 | nftContract.target, 159 | tokenId, 160 | 0, 161 | '0x' 162 | ); 163 | computedAddress = await registryContract.account( 164 | erc6551Implementation.target, 165 | chainId, 166 | nftContract.target, 167 | tokenId, 168 | 0 169 | ); 170 | }); 171 | it('only allows owner to transfer funds', async () => { 172 | const value = hre.ethers.parseEther('0.0125'); 173 | const balanceBefore = await hre.ethers.provider.getBalance(computedAddress); 174 | console.log('Balance before: ', balanceBefore); 175 | await signer.sendTransaction({ to: computedAddress, value: value }); 176 | const balanceAfter = await hre.ethers.provider.getBalance(computedAddress); 177 | console.log(balanceAfter); 178 | console.log('token owner: ', await nftContract.ownerOf(tokenId)); 179 | await expect( 180 | erc6551Implementation.send(signer.address, hre.ethers.parseEther('.005')) 181 | ).to.be.reverted; 182 | }); 183 | }); 184 | -------------------------------------------------------------------------------- /bridge/native/abi/erc20.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { "internalType": "address[]", "name": "holders", "type": "address[]" }, 5 | { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } 6 | ], 7 | "stateMutability": "nonpayable", 8 | "type": "constructor" 9 | }, 10 | { 11 | "anonymous": false, 12 | "inputs": [ 13 | { 14 | "indexed": true, 15 | "internalType": "address", 16 | "name": "_owner", 17 | "type": "address" 18 | }, 19 | { 20 | "indexed": true, 21 | "internalType": "address", 22 | "name": "_spender", 23 | "type": "address" 24 | }, 25 | { 26 | "indexed": false, 27 | "internalType": "uint256", 28 | "name": "_value", 29 | "type": "uint256" 30 | } 31 | ], 32 | "name": "Approval", 33 | "type": "event" 34 | }, 35 | { 36 | "anonymous": false, 37 | "inputs": [ 38 | { 39 | "indexed": true, 40 | "internalType": "address", 41 | "name": "previousOwner", 42 | "type": "address" 43 | }, 44 | { 45 | "indexed": true, 46 | "internalType": "address", 47 | "name": "newOwner", 48 | "type": "address" 49 | } 50 | ], 51 | "name": "OwnershipTransferred", 52 | "type": "event" 53 | }, 54 | { 55 | "anonymous": false, 56 | "inputs": [ 57 | { 58 | "indexed": true, 59 | "internalType": "address", 60 | "name": "_from", 61 | "type": "address" 62 | }, 63 | { 64 | "indexed": true, 65 | "internalType": "address", 66 | "name": "_to", 67 | "type": "address" 68 | }, 69 | { 70 | "indexed": false, 71 | "internalType": "uint256", 72 | "name": "_value", 73 | "type": "uint256" 74 | } 75 | ], 76 | "name": "Transfer", 77 | "type": "event" 78 | }, 79 | { 80 | "anonymous": false, 81 | "inputs": [ 82 | { 83 | "indexed": false, 84 | "internalType": "address", 85 | "name": "operator", 86 | "type": "address" 87 | }, 88 | { 89 | "indexed": false, 90 | "internalType": "bool", 91 | "name": "enabled", 92 | "type": "bool" 93 | } 94 | ], 95 | "name": "WhitelistedOperator", 96 | "type": "event" 97 | }, 98 | { 99 | "inputs": [ 100 | { "internalType": "address", "name": "owner", "type": "address" }, 101 | { "internalType": "address", "name": "spender", "type": "address" } 102 | ], 103 | "name": "allowance", 104 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 105 | "stateMutability": "view", 106 | "type": "function" 107 | }, 108 | { 109 | "inputs": [ 110 | { "internalType": "address", "name": "spender", "type": "address" }, 111 | { "internalType": "uint256", "name": "amount", "type": "uint256" } 112 | ], 113 | "name": "approve", 114 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 115 | "stateMutability": "nonpayable", 116 | "type": "function" 117 | }, 118 | { 119 | "inputs": [ 120 | { "internalType": "address", "name": "account", "type": "address" } 121 | ], 122 | "name": "balanceOf", 123 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 124 | "stateMutability": "view", 125 | "type": "function" 126 | }, 127 | { 128 | "inputs": [], 129 | "name": "decimals", 130 | "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], 131 | "stateMutability": "view", 132 | "type": "function" 133 | }, 134 | { 135 | "inputs": [ 136 | { "internalType": "address", "name": "spender", "type": "address" }, 137 | { 138 | "internalType": "uint256", 139 | "name": "subtractedValue", 140 | "type": "uint256" 141 | } 142 | ], 143 | "name": "decreaseAllowance", 144 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 145 | "stateMutability": "nonpayable", 146 | "type": "function" 147 | }, 148 | { 149 | "inputs": [ 150 | { "internalType": "address", "name": "spender", "type": "address" }, 151 | { "internalType": "uint256", "name": "addedValue", "type": "uint256" } 152 | ], 153 | "name": "increaseAllowance", 154 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 155 | "stateMutability": "nonpayable", 156 | "type": "function" 157 | }, 158 | { 159 | "inputs": [{ "internalType": "address", "name": "who", "type": "address" }], 160 | "name": "isOperator", 161 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 162 | "stateMutability": "view", 163 | "type": "function" 164 | }, 165 | { 166 | "inputs": [], 167 | "name": "name", 168 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }], 169 | "stateMutability": "view", 170 | "type": "function" 171 | }, 172 | { 173 | "inputs": [], 174 | "name": "owner", 175 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }], 176 | "stateMutability": "view", 177 | "type": "function" 178 | }, 179 | { 180 | "inputs": [], 181 | "name": "renounceOwnership", 182 | "outputs": [], 183 | "stateMutability": "nonpayable", 184 | "type": "function" 185 | }, 186 | { 187 | "inputs": [ 188 | { "internalType": "bytes4", "name": "interfaceId", "type": "bytes4" } 189 | ], 190 | "name": "supportsInterface", 191 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 192 | "stateMutability": "view", 193 | "type": "function" 194 | }, 195 | { 196 | "inputs": [], 197 | "name": "symbol", 198 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }], 199 | "stateMutability": "view", 200 | "type": "function" 201 | }, 202 | { 203 | "inputs": [], 204 | "name": "totalSupply", 205 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 206 | "stateMutability": "view", 207 | "type": "function" 208 | }, 209 | { 210 | "inputs": [ 211 | { "internalType": "address", "name": "recipient", "type": "address" }, 212 | { "internalType": "uint256", "name": "amount", "type": "uint256" } 213 | ], 214 | "name": "transfer", 215 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 216 | "stateMutability": "nonpayable", 217 | "type": "function" 218 | }, 219 | { 220 | "inputs": [ 221 | { "internalType": "address", "name": "sender", "type": "address" }, 222 | { "internalType": "address", "name": "recipient", "type": "address" }, 223 | { "internalType": "uint256", "name": "amount", "type": "uint256" } 224 | ], 225 | "name": "transferFrom", 226 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 227 | "stateMutability": "nonpayable", 228 | "type": "function" 229 | }, 230 | { 231 | "inputs": [ 232 | { "internalType": "address", "name": "newOwner", "type": "address" } 233 | ], 234 | "name": "transferOwnership", 235 | "outputs": [], 236 | "stateMutability": "nonpayable", 237 | "type": "function" 238 | }, 239 | { 240 | "inputs": [ 241 | { "internalType": "address", "name": "operator", "type": "address" }, 242 | { "internalType": "bool", "name": "enabled", "type": "bool" } 243 | ], 244 | "name": "whitelistOperator", 245 | "outputs": [], 246 | "stateMutability": "nonpayable", 247 | "type": "function" 248 | } 249 | ] 250 | -------------------------------------------------------------------------------- /bridge/native/abi/l2OutputOracle.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "uint256", 6 | "name": "_submissionInterval", 7 | "type": "uint256" 8 | }, 9 | { "internalType": "uint256", "name": "_l2BlockTime", "type": "uint256" }, 10 | { 11 | "internalType": "uint256", 12 | "name": "_startingBlockNumber", 13 | "type": "uint256" 14 | }, 15 | { 16 | "internalType": "uint256", 17 | "name": "_startingTimestamp", 18 | "type": "uint256" 19 | }, 20 | { "internalType": "address", "name": "_proposer", "type": "address" }, 21 | { "internalType": "address", "name": "_challenger", "type": "address" }, 22 | { 23 | "internalType": "uint256", 24 | "name": "_finalizationPeriodSeconds", 25 | "type": "uint256" 26 | } 27 | ], 28 | "stateMutability": "nonpayable", 29 | "type": "constructor" 30 | }, 31 | { 32 | "anonymous": false, 33 | "inputs": [ 34 | { 35 | "indexed": false, 36 | "internalType": "uint8", 37 | "name": "version", 38 | "type": "uint8" 39 | } 40 | ], 41 | "name": "Initialized", 42 | "type": "event" 43 | }, 44 | { 45 | "anonymous": false, 46 | "inputs": [ 47 | { 48 | "indexed": true, 49 | "internalType": "bytes32", 50 | "name": "outputRoot", 51 | "type": "bytes32" 52 | }, 53 | { 54 | "indexed": true, 55 | "internalType": "uint256", 56 | "name": "l2OutputIndex", 57 | "type": "uint256" 58 | }, 59 | { 60 | "indexed": true, 61 | "internalType": "uint256", 62 | "name": "l2BlockNumber", 63 | "type": "uint256" 64 | }, 65 | { 66 | "indexed": false, 67 | "internalType": "uint256", 68 | "name": "l1Timestamp", 69 | "type": "uint256" 70 | } 71 | ], 72 | "name": "OutputProposed", 73 | "type": "event" 74 | }, 75 | { 76 | "anonymous": false, 77 | "inputs": [ 78 | { 79 | "indexed": true, 80 | "internalType": "uint256", 81 | "name": "prevNextOutputIndex", 82 | "type": "uint256" 83 | }, 84 | { 85 | "indexed": true, 86 | "internalType": "uint256", 87 | "name": "newNextOutputIndex", 88 | "type": "uint256" 89 | } 90 | ], 91 | "name": "OutputsDeleted", 92 | "type": "event" 93 | }, 94 | { 95 | "inputs": [], 96 | "name": "CHALLENGER", 97 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }], 98 | "stateMutability": "view", 99 | "type": "function" 100 | }, 101 | { 102 | "inputs": [], 103 | "name": "FINALIZATION_PERIOD_SECONDS", 104 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 105 | "stateMutability": "view", 106 | "type": "function" 107 | }, 108 | { 109 | "inputs": [], 110 | "name": "L2_BLOCK_TIME", 111 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 112 | "stateMutability": "view", 113 | "type": "function" 114 | }, 115 | { 116 | "inputs": [], 117 | "name": "PROPOSER", 118 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }], 119 | "stateMutability": "view", 120 | "type": "function" 121 | }, 122 | { 123 | "inputs": [], 124 | "name": "SUBMISSION_INTERVAL", 125 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 126 | "stateMutability": "view", 127 | "type": "function" 128 | }, 129 | { 130 | "inputs": [ 131 | { "internalType": "uint256", "name": "_l2BlockNumber", "type": "uint256" } 132 | ], 133 | "name": "computeL2Timestamp", 134 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 135 | "stateMutability": "view", 136 | "type": "function" 137 | }, 138 | { 139 | "inputs": [ 140 | { "internalType": "uint256", "name": "_l2OutputIndex", "type": "uint256" } 141 | ], 142 | "name": "deleteL2Outputs", 143 | "outputs": [], 144 | "stateMutability": "nonpayable", 145 | "type": "function" 146 | }, 147 | { 148 | "inputs": [ 149 | { "internalType": "uint256", "name": "_l2OutputIndex", "type": "uint256" } 150 | ], 151 | "name": "getL2Output", 152 | "outputs": [ 153 | { 154 | "components": [ 155 | { 156 | "internalType": "bytes32", 157 | "name": "outputRoot", 158 | "type": "bytes32" 159 | }, 160 | { "internalType": "uint128", "name": "timestamp", "type": "uint128" }, 161 | { 162 | "internalType": "uint128", 163 | "name": "l2BlockNumber", 164 | "type": "uint128" 165 | } 166 | ], 167 | "internalType": "struct Types.OutputProposal", 168 | "name": "", 169 | "type": "tuple" 170 | } 171 | ], 172 | "stateMutability": "view", 173 | "type": "function" 174 | }, 175 | { 176 | "inputs": [ 177 | { "internalType": "uint256", "name": "_l2BlockNumber", "type": "uint256" } 178 | ], 179 | "name": "getL2OutputAfter", 180 | "outputs": [ 181 | { 182 | "components": [ 183 | { 184 | "internalType": "bytes32", 185 | "name": "outputRoot", 186 | "type": "bytes32" 187 | }, 188 | { "internalType": "uint128", "name": "timestamp", "type": "uint128" }, 189 | { 190 | "internalType": "uint128", 191 | "name": "l2BlockNumber", 192 | "type": "uint128" 193 | } 194 | ], 195 | "internalType": "struct Types.OutputProposal", 196 | "name": "", 197 | "type": "tuple" 198 | } 199 | ], 200 | "stateMutability": "view", 201 | "type": "function" 202 | }, 203 | { 204 | "inputs": [ 205 | { "internalType": "uint256", "name": "_l2BlockNumber", "type": "uint256" } 206 | ], 207 | "name": "getL2OutputIndexAfter", 208 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 209 | "stateMutability": "view", 210 | "type": "function" 211 | }, 212 | { 213 | "inputs": [ 214 | { 215 | "internalType": "uint256", 216 | "name": "_startingBlockNumber", 217 | "type": "uint256" 218 | }, 219 | { 220 | "internalType": "uint256", 221 | "name": "_startingTimestamp", 222 | "type": "uint256" 223 | } 224 | ], 225 | "name": "initialize", 226 | "outputs": [], 227 | "stateMutability": "nonpayable", 228 | "type": "function" 229 | }, 230 | { 231 | "inputs": [], 232 | "name": "latestBlockNumber", 233 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 234 | "stateMutability": "view", 235 | "type": "function" 236 | }, 237 | { 238 | "inputs": [], 239 | "name": "latestOutputIndex", 240 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 241 | "stateMutability": "view", 242 | "type": "function" 243 | }, 244 | { 245 | "inputs": [], 246 | "name": "nextBlockNumber", 247 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 248 | "stateMutability": "view", 249 | "type": "function" 250 | }, 251 | { 252 | "inputs": [], 253 | "name": "nextOutputIndex", 254 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 255 | "stateMutability": "view", 256 | "type": "function" 257 | }, 258 | { 259 | "inputs": [ 260 | { "internalType": "bytes32", "name": "_outputRoot", "type": "bytes32" }, 261 | { 262 | "internalType": "uint256", 263 | "name": "_l2BlockNumber", 264 | "type": "uint256" 265 | }, 266 | { "internalType": "bytes32", "name": "_l1BlockHash", "type": "bytes32" }, 267 | { "internalType": "uint256", "name": "_l1BlockNumber", "type": "uint256" } 268 | ], 269 | "name": "proposeL2Output", 270 | "outputs": [], 271 | "stateMutability": "payable", 272 | "type": "function" 273 | }, 274 | { 275 | "inputs": [], 276 | "name": "startingBlockNumber", 277 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 278 | "stateMutability": "view", 279 | "type": "function" 280 | }, 281 | { 282 | "inputs": [], 283 | "name": "startingTimestamp", 284 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 285 | "stateMutability": "view", 286 | "type": "function" 287 | }, 288 | { 289 | "inputs": [], 290 | "name": "version", 291 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }], 292 | "stateMutability": "view", 293 | "type": "function" 294 | } 295 | ] 296 | -------------------------------------------------------------------------------- /bridge/native/abi/optimismPortal.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "contract L2OutputOracle", 6 | "name": "_l2Oracle", 7 | "type": "address" 8 | }, 9 | { "internalType": "address", "name": "_guardian", "type": "address" }, 10 | { "internalType": "bool", "name": "_paused", "type": "bool" }, 11 | { 12 | "internalType": "contract SystemConfig", 13 | "name": "_config", 14 | "type": "address" 15 | } 16 | ], 17 | "stateMutability": "nonpayable", 18 | "type": "constructor" 19 | }, 20 | { 21 | "anonymous": false, 22 | "inputs": [ 23 | { 24 | "indexed": false, 25 | "internalType": "uint8", 26 | "name": "version", 27 | "type": "uint8" 28 | } 29 | ], 30 | "name": "Initialized", 31 | "type": "event" 32 | }, 33 | { 34 | "anonymous": false, 35 | "inputs": [ 36 | { 37 | "indexed": false, 38 | "internalType": "address", 39 | "name": "account", 40 | "type": "address" 41 | } 42 | ], 43 | "name": "Paused", 44 | "type": "event" 45 | }, 46 | { 47 | "anonymous": false, 48 | "inputs": [ 49 | { 50 | "indexed": true, 51 | "internalType": "address", 52 | "name": "from", 53 | "type": "address" 54 | }, 55 | { 56 | "indexed": true, 57 | "internalType": "address", 58 | "name": "to", 59 | "type": "address" 60 | }, 61 | { 62 | "indexed": true, 63 | "internalType": "uint256", 64 | "name": "version", 65 | "type": "uint256" 66 | }, 67 | { 68 | "indexed": false, 69 | "internalType": "bytes", 70 | "name": "opaqueData", 71 | "type": "bytes" 72 | } 73 | ], 74 | "name": "TransactionDeposited", 75 | "type": "event" 76 | }, 77 | { 78 | "anonymous": false, 79 | "inputs": [ 80 | { 81 | "indexed": false, 82 | "internalType": "address", 83 | "name": "account", 84 | "type": "address" 85 | } 86 | ], 87 | "name": "Unpaused", 88 | "type": "event" 89 | }, 90 | { 91 | "anonymous": false, 92 | "inputs": [ 93 | { 94 | "indexed": true, 95 | "internalType": "bytes32", 96 | "name": "withdrawalHash", 97 | "type": "bytes32" 98 | }, 99 | { 100 | "indexed": false, 101 | "internalType": "bool", 102 | "name": "success", 103 | "type": "bool" 104 | } 105 | ], 106 | "name": "WithdrawalFinalized", 107 | "type": "event" 108 | }, 109 | { 110 | "anonymous": false, 111 | "inputs": [ 112 | { 113 | "indexed": true, 114 | "internalType": "bytes32", 115 | "name": "withdrawalHash", 116 | "type": "bytes32" 117 | }, 118 | { 119 | "indexed": true, 120 | "internalType": "address", 121 | "name": "from", 122 | "type": "address" 123 | }, 124 | { 125 | "indexed": true, 126 | "internalType": "address", 127 | "name": "to", 128 | "type": "address" 129 | } 130 | ], 131 | "name": "WithdrawalProven", 132 | "type": "event" 133 | }, 134 | { 135 | "inputs": [], 136 | "name": "GUARDIAN", 137 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }], 138 | "stateMutability": "view", 139 | "type": "function" 140 | }, 141 | { 142 | "inputs": [], 143 | "name": "L2_ORACLE", 144 | "outputs": [ 145 | { 146 | "internalType": "contract L2OutputOracle", 147 | "name": "", 148 | "type": "address" 149 | } 150 | ], 151 | "stateMutability": "view", 152 | "type": "function" 153 | }, 154 | { 155 | "inputs": [], 156 | "name": "SYSTEM_CONFIG", 157 | "outputs": [ 158 | { "internalType": "contract SystemConfig", "name": "", "type": "address" } 159 | ], 160 | "stateMutability": "view", 161 | "type": "function" 162 | }, 163 | { 164 | "inputs": [ 165 | { "internalType": "address", "name": "_to", "type": "address" }, 166 | { "internalType": "uint256", "name": "_value", "type": "uint256" }, 167 | { "internalType": "uint64", "name": "_gasLimit", "type": "uint64" }, 168 | { "internalType": "bool", "name": "_isCreation", "type": "bool" }, 169 | { "internalType": "bytes", "name": "_data", "type": "bytes" } 170 | ], 171 | "name": "depositTransaction", 172 | "outputs": [], 173 | "stateMutability": "payable", 174 | "type": "function" 175 | }, 176 | { 177 | "inputs": [], 178 | "name": "donateETH", 179 | "outputs": [], 180 | "stateMutability": "payable", 181 | "type": "function" 182 | }, 183 | { 184 | "inputs": [ 185 | { 186 | "components": [ 187 | { "internalType": "uint256", "name": "nonce", "type": "uint256" }, 188 | { "internalType": "address", "name": "sender", "type": "address" }, 189 | { "internalType": "address", "name": "target", "type": "address" }, 190 | { "internalType": "uint256", "name": "value", "type": "uint256" }, 191 | { "internalType": "uint256", "name": "gasLimit", "type": "uint256" }, 192 | { "internalType": "bytes", "name": "data", "type": "bytes" } 193 | ], 194 | "internalType": "struct Types.WithdrawalTransaction", 195 | "name": "_tx", 196 | "type": "tuple" 197 | } 198 | ], 199 | "name": "finalizeWithdrawalTransaction", 200 | "outputs": [], 201 | "stateMutability": "nonpayable", 202 | "type": "function" 203 | }, 204 | { 205 | "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], 206 | "name": "finalizedWithdrawals", 207 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 208 | "stateMutability": "view", 209 | "type": "function" 210 | }, 211 | { 212 | "inputs": [{ "internalType": "bool", "name": "_paused", "type": "bool" }], 213 | "name": "initialize", 214 | "outputs": [], 215 | "stateMutability": "nonpayable", 216 | "type": "function" 217 | }, 218 | { 219 | "inputs": [ 220 | { "internalType": "uint256", "name": "_l2OutputIndex", "type": "uint256" } 221 | ], 222 | "name": "isOutputFinalized", 223 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 224 | "stateMutability": "view", 225 | "type": "function" 226 | }, 227 | { 228 | "inputs": [], 229 | "name": "l2Sender", 230 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }], 231 | "stateMutability": "view", 232 | "type": "function" 233 | }, 234 | { 235 | "inputs": [ 236 | { "internalType": "uint64", "name": "_byteCount", "type": "uint64" } 237 | ], 238 | "name": "minimumGasLimit", 239 | "outputs": [{ "internalType": "uint64", "name": "", "type": "uint64" }], 240 | "stateMutability": "pure", 241 | "type": "function" 242 | }, 243 | { 244 | "inputs": [], 245 | "name": "params", 246 | "outputs": [ 247 | { "internalType": "uint128", "name": "prevBaseFee", "type": "uint128" }, 248 | { "internalType": "uint64", "name": "prevBoughtGas", "type": "uint64" }, 249 | { "internalType": "uint64", "name": "prevBlockNum", "type": "uint64" } 250 | ], 251 | "stateMutability": "view", 252 | "type": "function" 253 | }, 254 | { 255 | "inputs": [], 256 | "name": "pause", 257 | "outputs": [], 258 | "stateMutability": "nonpayable", 259 | "type": "function" 260 | }, 261 | { 262 | "inputs": [], 263 | "name": "paused", 264 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 265 | "stateMutability": "view", 266 | "type": "function" 267 | }, 268 | { 269 | "inputs": [ 270 | { 271 | "components": [ 272 | { "internalType": "uint256", "name": "nonce", "type": "uint256" }, 273 | { "internalType": "address", "name": "sender", "type": "address" }, 274 | { "internalType": "address", "name": "target", "type": "address" }, 275 | { "internalType": "uint256", "name": "value", "type": "uint256" }, 276 | { "internalType": "uint256", "name": "gasLimit", "type": "uint256" }, 277 | { "internalType": "bytes", "name": "data", "type": "bytes" } 278 | ], 279 | "internalType": "struct Types.WithdrawalTransaction", 280 | "name": "_tx", 281 | "type": "tuple" 282 | }, 283 | { 284 | "internalType": "uint256", 285 | "name": "_l2OutputIndex", 286 | "type": "uint256" 287 | }, 288 | { 289 | "components": [ 290 | { "internalType": "bytes32", "name": "version", "type": "bytes32" }, 291 | { "internalType": "bytes32", "name": "stateRoot", "type": "bytes32" }, 292 | { 293 | "internalType": "bytes32", 294 | "name": "messagePasserStorageRoot", 295 | "type": "bytes32" 296 | }, 297 | { 298 | "internalType": "bytes32", 299 | "name": "latestBlockhash", 300 | "type": "bytes32" 301 | } 302 | ], 303 | "internalType": "struct Types.OutputRootProof", 304 | "name": "_outputRootProof", 305 | "type": "tuple" 306 | }, 307 | { 308 | "internalType": "bytes[]", 309 | "name": "_withdrawalProof", 310 | "type": "bytes[]" 311 | } 312 | ], 313 | "name": "proveWithdrawalTransaction", 314 | "outputs": [], 315 | "stateMutability": "nonpayable", 316 | "type": "function" 317 | }, 318 | { 319 | "inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], 320 | "name": "provenWithdrawals", 321 | "outputs": [ 322 | { "internalType": "bytes32", "name": "outputRoot", "type": "bytes32" }, 323 | { "internalType": "uint128", "name": "timestamp", "type": "uint128" }, 324 | { "internalType": "uint128", "name": "l2OutputIndex", "type": "uint128" } 325 | ], 326 | "stateMutability": "view", 327 | "type": "function" 328 | }, 329 | { 330 | "inputs": [], 331 | "name": "unpause", 332 | "outputs": [], 333 | "stateMutability": "nonpayable", 334 | "type": "function" 335 | }, 336 | { 337 | "inputs": [], 338 | "name": "version", 339 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }], 340 | "stateMutability": "view", 341 | "type": "function" 342 | }, 343 | { "stateMutability": "payable", "type": "receive" } 344 | ] 345 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2023 Coinbase 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /erc/6551/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2023 Coinbase 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /bridge/native/abi/l2standardbridge.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "address payable", 6 | "name": "_otherBridge", 7 | "type": "address" 8 | } 9 | ], 10 | "stateMutability": "nonpayable", 11 | "type": "constructor" 12 | }, 13 | { 14 | "anonymous": false, 15 | "inputs": [ 16 | { 17 | "indexed": true, 18 | "internalType": "address", 19 | "name": "l1Token", 20 | "type": "address" 21 | }, 22 | { 23 | "indexed": true, 24 | "internalType": "address", 25 | "name": "l2Token", 26 | "type": "address" 27 | }, 28 | { 29 | "indexed": true, 30 | "internalType": "address", 31 | "name": "from", 32 | "type": "address" 33 | }, 34 | { 35 | "indexed": false, 36 | "internalType": "address", 37 | "name": "to", 38 | "type": "address" 39 | }, 40 | { 41 | "indexed": false, 42 | "internalType": "uint256", 43 | "name": "amount", 44 | "type": "uint256" 45 | }, 46 | { 47 | "indexed": false, 48 | "internalType": "bytes", 49 | "name": "extraData", 50 | "type": "bytes" 51 | } 52 | ], 53 | "name": "DepositFinalized", 54 | "type": "event" 55 | }, 56 | { 57 | "anonymous": false, 58 | "inputs": [ 59 | { 60 | "indexed": true, 61 | "internalType": "address", 62 | "name": "localToken", 63 | "type": "address" 64 | }, 65 | { 66 | "indexed": true, 67 | "internalType": "address", 68 | "name": "remoteToken", 69 | "type": "address" 70 | }, 71 | { 72 | "indexed": true, 73 | "internalType": "address", 74 | "name": "from", 75 | "type": "address" 76 | }, 77 | { 78 | "indexed": false, 79 | "internalType": "address", 80 | "name": "to", 81 | "type": "address" 82 | }, 83 | { 84 | "indexed": false, 85 | "internalType": "uint256", 86 | "name": "amount", 87 | "type": "uint256" 88 | }, 89 | { 90 | "indexed": false, 91 | "internalType": "bytes", 92 | "name": "extraData", 93 | "type": "bytes" 94 | } 95 | ], 96 | "name": "ERC20BridgeFinalized", 97 | "type": "event" 98 | }, 99 | { 100 | "anonymous": false, 101 | "inputs": [ 102 | { 103 | "indexed": true, 104 | "internalType": "address", 105 | "name": "localToken", 106 | "type": "address" 107 | }, 108 | { 109 | "indexed": true, 110 | "internalType": "address", 111 | "name": "remoteToken", 112 | "type": "address" 113 | }, 114 | { 115 | "indexed": true, 116 | "internalType": "address", 117 | "name": "from", 118 | "type": "address" 119 | }, 120 | { 121 | "indexed": false, 122 | "internalType": "address", 123 | "name": "to", 124 | "type": "address" 125 | }, 126 | { 127 | "indexed": false, 128 | "internalType": "uint256", 129 | "name": "amount", 130 | "type": "uint256" 131 | }, 132 | { 133 | "indexed": false, 134 | "internalType": "bytes", 135 | "name": "extraData", 136 | "type": "bytes" 137 | } 138 | ], 139 | "name": "ERC20BridgeInitiated", 140 | "type": "event" 141 | }, 142 | { 143 | "anonymous": false, 144 | "inputs": [ 145 | { 146 | "indexed": true, 147 | "internalType": "address", 148 | "name": "from", 149 | "type": "address" 150 | }, 151 | { 152 | "indexed": true, 153 | "internalType": "address", 154 | "name": "to", 155 | "type": "address" 156 | }, 157 | { 158 | "indexed": false, 159 | "internalType": "uint256", 160 | "name": "amount", 161 | "type": "uint256" 162 | }, 163 | { 164 | "indexed": false, 165 | "internalType": "bytes", 166 | "name": "extraData", 167 | "type": "bytes" 168 | } 169 | ], 170 | "name": "ETHBridgeFinalized", 171 | "type": "event" 172 | }, 173 | { 174 | "anonymous": false, 175 | "inputs": [ 176 | { 177 | "indexed": true, 178 | "internalType": "address", 179 | "name": "from", 180 | "type": "address" 181 | }, 182 | { 183 | "indexed": true, 184 | "internalType": "address", 185 | "name": "to", 186 | "type": "address" 187 | }, 188 | { 189 | "indexed": false, 190 | "internalType": "uint256", 191 | "name": "amount", 192 | "type": "uint256" 193 | }, 194 | { 195 | "indexed": false, 196 | "internalType": "bytes", 197 | "name": "extraData", 198 | "type": "bytes" 199 | } 200 | ], 201 | "name": "ETHBridgeInitiated", 202 | "type": "event" 203 | }, 204 | { 205 | "anonymous": false, 206 | "inputs": [ 207 | { 208 | "indexed": true, 209 | "internalType": "address", 210 | "name": "l1Token", 211 | "type": "address" 212 | }, 213 | { 214 | "indexed": true, 215 | "internalType": "address", 216 | "name": "l2Token", 217 | "type": "address" 218 | }, 219 | { 220 | "indexed": true, 221 | "internalType": "address", 222 | "name": "from", 223 | "type": "address" 224 | }, 225 | { 226 | "indexed": false, 227 | "internalType": "address", 228 | "name": "to", 229 | "type": "address" 230 | }, 231 | { 232 | "indexed": false, 233 | "internalType": "uint256", 234 | "name": "amount", 235 | "type": "uint256" 236 | }, 237 | { 238 | "indexed": false, 239 | "internalType": "bytes", 240 | "name": "extraData", 241 | "type": "bytes" 242 | } 243 | ], 244 | "name": "WithdrawalInitiated", 245 | "type": "event" 246 | }, 247 | { 248 | "inputs": [], 249 | "name": "MESSENGER", 250 | "outputs": [ 251 | { 252 | "internalType": "contract CrossDomainMessenger", 253 | "name": "", 254 | "type": "address" 255 | } 256 | ], 257 | "stateMutability": "view", 258 | "type": "function" 259 | }, 260 | { 261 | "inputs": [], 262 | "name": "OTHER_BRIDGE", 263 | "outputs": [ 264 | { 265 | "internalType": "contract StandardBridge", 266 | "name": "", 267 | "type": "address" 268 | } 269 | ], 270 | "stateMutability": "view", 271 | "type": "function" 272 | }, 273 | { 274 | "inputs": [ 275 | { "internalType": "address", "name": "_localToken", "type": "address" }, 276 | { "internalType": "address", "name": "_remoteToken", "type": "address" }, 277 | { "internalType": "uint256", "name": "_amount", "type": "uint256" }, 278 | { "internalType": "uint32", "name": "_minGasLimit", "type": "uint32" }, 279 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 280 | ], 281 | "name": "bridgeERC20", 282 | "outputs": [], 283 | "stateMutability": "nonpayable", 284 | "type": "function" 285 | }, 286 | { 287 | "inputs": [ 288 | { "internalType": "address", "name": "_localToken", "type": "address" }, 289 | { "internalType": "address", "name": "_remoteToken", "type": "address" }, 290 | { "internalType": "address", "name": "_to", "type": "address" }, 291 | { "internalType": "uint256", "name": "_amount", "type": "uint256" }, 292 | { "internalType": "uint32", "name": "_minGasLimit", "type": "uint32" }, 293 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 294 | ], 295 | "name": "bridgeERC20To", 296 | "outputs": [], 297 | "stateMutability": "nonpayable", 298 | "type": "function" 299 | }, 300 | { 301 | "inputs": [ 302 | { "internalType": "uint32", "name": "_minGasLimit", "type": "uint32" }, 303 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 304 | ], 305 | "name": "bridgeETH", 306 | "outputs": [], 307 | "stateMutability": "payable", 308 | "type": "function" 309 | }, 310 | { 311 | "inputs": [ 312 | { "internalType": "address", "name": "_to", "type": "address" }, 313 | { "internalType": "uint32", "name": "_minGasLimit", "type": "uint32" }, 314 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 315 | ], 316 | "name": "bridgeETHTo", 317 | "outputs": [], 318 | "stateMutability": "payable", 319 | "type": "function" 320 | }, 321 | { 322 | "inputs": [ 323 | { "internalType": "address", "name": "", "type": "address" }, 324 | { "internalType": "address", "name": "", "type": "address" } 325 | ], 326 | "name": "deposits", 327 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 328 | "stateMutability": "view", 329 | "type": "function" 330 | }, 331 | { 332 | "inputs": [ 333 | { "internalType": "address", "name": "_localToken", "type": "address" }, 334 | { "internalType": "address", "name": "_remoteToken", "type": "address" }, 335 | { "internalType": "address", "name": "_from", "type": "address" }, 336 | { "internalType": "address", "name": "_to", "type": "address" }, 337 | { "internalType": "uint256", "name": "_amount", "type": "uint256" }, 338 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 339 | ], 340 | "name": "finalizeBridgeERC20", 341 | "outputs": [], 342 | "stateMutability": "nonpayable", 343 | "type": "function" 344 | }, 345 | { 346 | "inputs": [ 347 | { "internalType": "address", "name": "_from", "type": "address" }, 348 | { "internalType": "address", "name": "_to", "type": "address" }, 349 | { "internalType": "uint256", "name": "_amount", "type": "uint256" }, 350 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 351 | ], 352 | "name": "finalizeBridgeETH", 353 | "outputs": [], 354 | "stateMutability": "payable", 355 | "type": "function" 356 | }, 357 | { 358 | "inputs": [ 359 | { "internalType": "address", "name": "_l1Token", "type": "address" }, 360 | { "internalType": "address", "name": "_l2Token", "type": "address" }, 361 | { "internalType": "address", "name": "_from", "type": "address" }, 362 | { "internalType": "address", "name": "_to", "type": "address" }, 363 | { "internalType": "uint256", "name": "_amount", "type": "uint256" }, 364 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 365 | ], 366 | "name": "finalizeDeposit", 367 | "outputs": [], 368 | "stateMutability": "payable", 369 | "type": "function" 370 | }, 371 | { 372 | "inputs": [], 373 | "name": "l1TokenBridge", 374 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }], 375 | "stateMutability": "view", 376 | "type": "function" 377 | }, 378 | { 379 | "inputs": [], 380 | "name": "messenger", 381 | "outputs": [ 382 | { 383 | "internalType": "contract CrossDomainMessenger", 384 | "name": "", 385 | "type": "address" 386 | } 387 | ], 388 | "stateMutability": "view", 389 | "type": "function" 390 | }, 391 | { 392 | "inputs": [], 393 | "name": "version", 394 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }], 395 | "stateMutability": "view", 396 | "type": "function" 397 | }, 398 | { 399 | "inputs": [ 400 | { "internalType": "address", "name": "_l2Token", "type": "address" }, 401 | { "internalType": "uint256", "name": "_amount", "type": "uint256" }, 402 | { "internalType": "uint32", "name": "_minGasLimit", "type": "uint32" }, 403 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 404 | ], 405 | "name": "withdraw", 406 | "outputs": [], 407 | "stateMutability": "payable", 408 | "type": "function" 409 | }, 410 | { 411 | "inputs": [ 412 | { "internalType": "address", "name": "_l2Token", "type": "address" }, 413 | { "internalType": "address", "name": "_to", "type": "address" }, 414 | { "internalType": "uint256", "name": "_amount", "type": "uint256" }, 415 | { "internalType": "uint32", "name": "_minGasLimit", "type": "uint32" }, 416 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 417 | ], 418 | "name": "withdrawTo", 419 | "outputs": [], 420 | "stateMutability": "payable", 421 | "type": "function" 422 | }, 423 | { "stateMutability": "payable", "type": "receive" } 424 | ] 425 | -------------------------------------------------------------------------------- /erc/6551/README.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | [EIP-6551](https://eips.ethereum.org/EIPS/eip-6551) enhances the features of NFTs (ERC-721 tokens) by giving each token its own smart contract account, also known as token-bound accounts (TBA). These smart contract accounts equip NFTs with the ability to operate like traditional blockchain wallets, allowing state changes and features such as holding ERC-20 tokens, other NFTs, and ether. Programmable accounts open up a myriad of use cases, limited only by the developer's imagination and the protocol's constraints. 4 | 5 | Importantly, EIP-6551 is backwards compatible and doesn't mandate custom logic within the NFT smart contract. This compatibility allows NFT projects that were created before the introduction of EIP-6551 to adopt smart contract accounts via a [permissionless registry](https://eips.ethereum.org/EIPS/eip-6551#registry). 6 | 7 | # Use cases for token bound accounts: 8 | 9 | - **Gaming** - A character, represented as an NFT, can possess its own inventory (like weapons, gold, etc.) using a smart wallet 10 | - **Investing** - Utilize NFTs and their smart contract accounts to organize assets and sell entire investment portfolios in a single transaction 11 | - **Social (DAOs)** - NFTs representing DAO membership can now maintain their own transaction history 12 | 13 | # Create an NFT with a Token Bound Account 14 | 15 | This guide demonstrates how to create and interact with three smart contracts: 16 | 17 | 1. An [ERC-721](https://docs.openzeppelin.com/contracts/4.x/erc721) smart contract that serves as our NFT. 18 | 2. A [registry contract](https://eips.ethereum.org/EIPS/eip-6551) that deploys smart contract account associated with a given ERC-721 and computes the token bound account address. 19 | 3. A token bound account contract that can send and receive ether and other ERC-20 tokens. 20 | 21 | # Tools 22 | 23 | We will use a few tools to write and deploy our smart contracts: 24 | 25 | | Tool | Description | 26 | | ------------------------------------------------------ | ------------------------------------------------------------------------------ | 27 | | [Hardhat](https://hardhat.org/) | Helps deploy and interact with smart contracts | 28 | | [Node.js](https://nodejs.org/en) | Developer environment | 29 | | [OpenZeppelin](https://www.openzeppelin.com/contracts) | An open library for building secure smart contracts | 30 | | [Coinbase Wallet](https://www.coinbase.com/wallet/) | Non-custodial wallet for creating accounts and interacting with the blockchain | 31 | 32 | # Getting started 33 | 34 | We will be deploying these smart contracts on the [Base](https://docs.base.org/) Goerli testnet allowing us to see transaction information on [BaseScan](https://goerli.basescan.org/). 35 | 36 | Using a testnet requires us to obtain testnet funds from a [faucet](https://coinbase.com/faucets) to deploy and interact with our smart contracts on that network. 37 | 38 | ## Configure Coinbase Wallet for testnet interactions 39 | 40 | _**Warning**: This demo requires the use of private keys in order to effectively interact with the blockchain. For this demo, use newly created wallets as a safety measure._ 41 | 42 | _Depending on system settings your wallet may look different_ 43 | 44 | **Open the Coinbase Wallet browser extension then click on the Settings tab** 45 | 46 | ![Settings tab](images/enable_testnet_resize.png) 47 | 48 | **Select "Developer Settings"** 49 | 50 | ![Developer settings](images/enable_testnet_settings_resize.png) 51 | 52 | #### Toggle "Testnets" on 53 | 54 | ![Enable testnets](images/enable_testnet_toggle_resize.png) 55 | 56 | ## Request Testnet Funds 57 | 58 | **Click on the Settings tab** 59 | 60 | ![Settings tab](images/enable_testnet_resize.png) 61 | 62 | **Select "Networks"** 63 | 64 | ![Networks tab](images/testnet_networks_resize.png) 65 | 66 | **Select "Testnets" tab** 67 | 68 | ![Testnets](images/testnet_select_tab_resize.png) 69 | 70 | **Click on the water (💧) icon** 71 | 72 | ![Request funds](images/testnet_base_resize.png) 73 | 74 | **Request testnet funds** 75 | 76 | ![Request funds](images/testnet_base_request_resize.png) 77 | 78 | Alternatively, use the [base faucet](https://coinbase.com/faucets/base-ethereum-goerli-faucet) 79 | 80 | ## Environment Setup 81 | 82 | **Clone this repo** 83 | 84 | ```bash 85 | git clone https://github.com/base-org/guides.git 86 | ``` 87 | 88 | **Change into the directory** 89 | 90 | ```bash 91 | cd base-guides/6551 92 | ``` 93 | 94 | **Initiate a node project and install dependencies:** 95 | 96 | The dependencies in this project are as follows: 97 | 98 | | Dependencies | Description | 99 | | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | 100 | | [hardhat](https://hardhat.org/) | Helps deploy and interact with smart contracts | 101 | | [hardhat-toolbox](https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-toolbox) | Bundles all the commonly used packages and Hardhat plugins we recommend to start developing with Hardhat. | 102 | | [dot-env](https://www.npmjs.com/package/dotenv) | Dotenv is a zero-dependency module that loads environment variables from a .env file into process.env | 103 | | [openzeppelin/contracts](https://www.npmjs.com/package/@openzeppelin/contracts) | A library for secure smart contract development. | 104 | 105 | **Install them by running:** 106 | 107 | ```bash 108 | npm install 109 | ``` 110 | 111 | # Wallet setup 112 | 113 | Assuming you have set up your wallet (and safely stored away your seed phrase) and have some funds (testnet or mainnet), obtain the addresses and private keys needed for the demo. 114 | 115 | ## Copy your private key 116 | 117 | _Do not share your private key with anyone._ 118 | 119 | **Click on the Settings tab** 120 | 121 | ![Settings tab](images/enable_testnet_resize.png) 122 | 123 | **Select "Developer Settings"** 124 | 125 | ![Developer settings](images/enable_testnet_settings_resize.png) 126 | 127 | **Click on "Show private key"** 128 | 129 | ![Show private key](images/private_keys_resize.png) 130 | 131 | **Enter password** 132 | 133 | ![Enter password](images/private_keys_show1_resize.png) 134 | 135 | **Read disclaimer to copy address** 136 | 137 | ![accept terms](images/private_keys_copy2cb_resize.png) 138 | 139 | **Type the following command into your terminal application**: 140 | 141 | ```bash 142 | export WALLET_KEY= 143 | ``` 144 | 145 | **Paste the private key after `export WALLET_KEY= `within your terminal** 146 | 147 | Your terminal should look like this 148 | 149 | ```bash 150 | export WALLET_KEY=0xde9be858da4a475276426320d5e9262ecfc3ba460bfac56360bfa6c4c28b4ee0 151 | ``` 152 | 153 | Press enter/return on your keyboard to save the value 154 | 155 | **Verify your private key has been saved:** 156 | 157 | ```bash 158 | echo $WALLET_KEY 159 | ``` 160 | 161 | **Sample output:** 162 | 163 | ```bash 164 | 0xde9be858da4a475276426320d5e9262ecfc3ba460bfac56360bfa6c4c28b4ee0 165 | ``` 166 | 167 | ## Obtain details of another account 168 | 169 | _Note: Each account will need funds in order to deploy contracts and interact with Base._ 170 | 171 | **From the assets tab, click on the current address/account** 172 | 173 | ![Assets tab](images/assets_tab_resize.png) 174 | 175 | **Select another wallet/account** 176 | 177 | If you do not have an additional account click the "Add & manage wallets" button to create a new account. 178 | 179 | ![Select another account](images/select_wallet_resize.png) 180 | 181 | **Copy the address of the newly selected account** 182 | 183 | ![Copy address](images/copy_address_resize.png) 184 | 185 | **Type the following command into your terminal application** 186 | 187 | Your terminal should look like this: 188 | 189 | ```bash 190 | export WALLET2_ADDR= 191 | ``` 192 | 193 | **Paste the address as an environment variable within your terminal** 194 | 195 | ```bash 196 | export WALLET2_ADDR=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 197 | ``` 198 | 199 | Press enter/return on your keyboard to save the value 200 | 201 | **Verify the account address has been saved:** 202 | 203 | ```bash 204 | echo $WALLET2_ADDR 205 | ``` 206 | 207 | **Sample output:** 208 | 209 | ```bash 210 | 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 211 | ``` 212 | 213 | **Save the private key of the currently selected account** 214 | 215 | Each account has its own private key. 216 | 217 | This wallet will be the original owner of the NFT minted later in this tutorial. You will need the private key of the currently selected wallet in order to transfer the ownership of the NFT. 218 | 219 | Refer to the [previous steps](#copy-your-private-key) for obtaining and copying your private keys and save them as an environment variable `WALLET2_KEY ` using your terminal. 220 | 221 | Example: 222 | 223 | ```bash 224 | export WALLET2_KEY=0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a 225 | ``` 226 | 227 | **Verify your private key has been saved:** 228 | 229 | ```bash 230 | echo $WALLET2_KEY 231 | ``` 232 | 233 | **Sample output:** 234 | 235 | ```bash 236 | 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a 237 | ``` 238 | 239 | ## Deploy contracts on the Base testnet 240 | 241 | The following script will deploy three smart contracts and save their deployment information in a file called `deploymentData.json`. 242 | 243 | Once you become comfortable deploying contracts on a testnet, you may deploy contracts on the Base mainnet by replacing `--network base-goerli ` with `--network base-mainnet` . 244 | 245 | ``` 246 | npx hardhat run scripts/01_deploy_contracts.js --network base-goerli 247 | ``` 248 | 249 | ### Sample output: 250 | 251 | ```bash 252 | ERC-721 Contract deployed at: 0xECD4b1C01a0aF70C7Ee985db389E294D01DffEC0 253 | Saved deployment data to a new file: deploymentData.json 254 | Deployed registry contract at: 0x58B2EAe6f05abf9C1e1566AD9307C67B41627A1e 255 | ``` 256 | 257 | ```bash 258 | [ 259 | { 260 | NftContract: { 261 | address: '0xECD4b1C01a0aF70C7Ee985db389E294D01DffEC0', 262 | deployer: '0xB6d00D83158feE6695C72ff9c5E915478A465724', 263 | deploymentHash: '0xedacc11c5268b155a9a6918b5e1cc19031343f41519f596eb264ef6ca3feaeb4' 264 | } 265 | }, 266 | { 267 | ERC6551Registry: { 268 | address: '0x58B2EAe6f05abf9C1e1566AD9307C67B41627A1e', 269 | deployer: '0xB6d00D83158feE6695C72ff9c5E915478A465724', 270 | deploymentHash: '0xcf45022f97e682eccc87c903c6eff38ba2c080aeb69c69da4662914aacf4f481' 271 | } 272 | } 273 | ] 274 | ``` 275 | 276 | ```bash 277 | Deployment data saved to: deploymentData.json 278 | Deploying Token Bound Account 279 | Token bound account deployed at: 0xdAcaEDF79Fa33405446F2B9Fbf820Cef84507f22 280 | ``` 281 | 282 | ```bash 283 | [ 284 | { 285 | NftContract: { 286 | address: '0xECD4b1C01a0aF70C7Ee985db389E294D01DffEC0', 287 | deployer: '0xB6d00D83158feE6695C72ff9c5E915478A465724', 288 | deploymentHash: '0xedacc11c5268b155a9a6918b5e1cc19031343f41519f596eb264ef6ca3feaeb4' 289 | } 290 | }, 291 | { 292 | ERC6551Registry: { 293 | address: '0x58B2EAe6f05abf9C1e1566AD9307C67B41627A1e', 294 | deployer: '0xB6d00D83158feE6695C72ff9c5E915478A465724', 295 | deploymentHash: '0xcf45022f97e682eccc87c903c6eff38ba2c080aeb69c69da4662914aacf4f481' 296 | } 297 | }, 298 | { 299 | ERC6551Account: { 300 | address: '0xdAcaEDF79Fa33405446F2B9Fbf820Cef84507f22', 301 | deployer: '0xB6d00D83158feE6695C72ff9c5E915478A465724', 302 | deploymentHash: '0xbfe9ab08951e07660c2d3a6e9b16e6e959a174530f1e28aba9c98a19c381f586' 303 | } 304 | } 305 | ] 306 | ``` 307 | 308 | ```bash 309 | Deployment data saved to: deploymentData.json 310 | ``` 311 | 312 | This script will mint an NFT and assign its ownership to the `WALLET2_ADDR` account 313 | 314 | ```bash 315 | npx hardhat run scripts/02_mint_nft.js --network --network base-goerli 316 | ``` 317 | 318 | ### Sample output: 319 | 320 | ```bash 321 | 0xECD4b1C01a0aF70C7Ee985db389E294D01DffEC0 322 | Minting NFT... 323 | TokenId 0 is owned by address: 0x9eEd71442F60440b39Def927047e5823c0b208D4 324 | ``` 325 | 326 | This script will create and compute the address for a smart contract wallet (token bound account) 327 | 328 | ```bash 329 | npx hardhat run scripts/03_create_account.js --network base-goerli 330 | ``` 331 | 332 | ### Sample output: 333 | 334 | ``` 335 | Computed Address: 0xA5153E5D9A384e519fEa64D228797edb4a448d45 336 | ``` 337 | 338 | This script will send funds from `WALLET_KEY` to the token bound account and transfer ownership of the NFT from `WALLET2_ADDR` to `WALLET_KEY`. 339 | 340 | ```bash 341 | npx hardhat run scripts/04_account_interaction.js --network base-goerli 342 | ``` 343 | 344 | ### Sample output: 345 | 346 | ``` 347 | Current owner of tokenId 0 is 0x9eEd71442F60440b39Def927047e5823c0b208D4 348 | Token account has 0 ETH 349 | New owner of tokenId 0 is 0xB6d00D83158feE6695C72ff9c5E915478A465724 350 | Token account has 12500000000000000 ETH 351 | ``` 352 | 353 | # Congrats! 354 | 355 | Clear the private keys from your environment variables by running this command: 356 | 357 | ```bash 358 | export WALLET_KEY=nil 359 | export WALLET2_KEY=nil 360 | ``` 361 | -------------------------------------------------------------------------------- /bridge/native/abi/l1standardbridge.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "address payable", 6 | "name": "_messenger", 7 | "type": "address" 8 | } 9 | ], 10 | "stateMutability": "nonpayable", 11 | "type": "constructor" 12 | }, 13 | { 14 | "anonymous": false, 15 | "inputs": [ 16 | { 17 | "indexed": true, 18 | "internalType": "address", 19 | "name": "localToken", 20 | "type": "address" 21 | }, 22 | { 23 | "indexed": true, 24 | "internalType": "address", 25 | "name": "remoteToken", 26 | "type": "address" 27 | }, 28 | { 29 | "indexed": true, 30 | "internalType": "address", 31 | "name": "from", 32 | "type": "address" 33 | }, 34 | { 35 | "indexed": false, 36 | "internalType": "address", 37 | "name": "to", 38 | "type": "address" 39 | }, 40 | { 41 | "indexed": false, 42 | "internalType": "uint256", 43 | "name": "amount", 44 | "type": "uint256" 45 | }, 46 | { 47 | "indexed": false, 48 | "internalType": "bytes", 49 | "name": "extraData", 50 | "type": "bytes" 51 | } 52 | ], 53 | "name": "ERC20BridgeFinalized", 54 | "type": "event" 55 | }, 56 | { 57 | "anonymous": false, 58 | "inputs": [ 59 | { 60 | "indexed": true, 61 | "internalType": "address", 62 | "name": "localToken", 63 | "type": "address" 64 | }, 65 | { 66 | "indexed": true, 67 | "internalType": "address", 68 | "name": "remoteToken", 69 | "type": "address" 70 | }, 71 | { 72 | "indexed": true, 73 | "internalType": "address", 74 | "name": "from", 75 | "type": "address" 76 | }, 77 | { 78 | "indexed": false, 79 | "internalType": "address", 80 | "name": "to", 81 | "type": "address" 82 | }, 83 | { 84 | "indexed": false, 85 | "internalType": "uint256", 86 | "name": "amount", 87 | "type": "uint256" 88 | }, 89 | { 90 | "indexed": false, 91 | "internalType": "bytes", 92 | "name": "extraData", 93 | "type": "bytes" 94 | } 95 | ], 96 | "name": "ERC20BridgeInitiated", 97 | "type": "event" 98 | }, 99 | { 100 | "anonymous": false, 101 | "inputs": [ 102 | { 103 | "indexed": true, 104 | "internalType": "address", 105 | "name": "l1Token", 106 | "type": "address" 107 | }, 108 | { 109 | "indexed": true, 110 | "internalType": "address", 111 | "name": "l2Token", 112 | "type": "address" 113 | }, 114 | { 115 | "indexed": true, 116 | "internalType": "address", 117 | "name": "from", 118 | "type": "address" 119 | }, 120 | { 121 | "indexed": false, 122 | "internalType": "address", 123 | "name": "to", 124 | "type": "address" 125 | }, 126 | { 127 | "indexed": false, 128 | "internalType": "uint256", 129 | "name": "amount", 130 | "type": "uint256" 131 | }, 132 | { 133 | "indexed": false, 134 | "internalType": "bytes", 135 | "name": "extraData", 136 | "type": "bytes" 137 | } 138 | ], 139 | "name": "ERC20DepositInitiated", 140 | "type": "event" 141 | }, 142 | { 143 | "anonymous": false, 144 | "inputs": [ 145 | { 146 | "indexed": true, 147 | "internalType": "address", 148 | "name": "l1Token", 149 | "type": "address" 150 | }, 151 | { 152 | "indexed": true, 153 | "internalType": "address", 154 | "name": "l2Token", 155 | "type": "address" 156 | }, 157 | { 158 | "indexed": true, 159 | "internalType": "address", 160 | "name": "from", 161 | "type": "address" 162 | }, 163 | { 164 | "indexed": false, 165 | "internalType": "address", 166 | "name": "to", 167 | "type": "address" 168 | }, 169 | { 170 | "indexed": false, 171 | "internalType": "uint256", 172 | "name": "amount", 173 | "type": "uint256" 174 | }, 175 | { 176 | "indexed": false, 177 | "internalType": "bytes", 178 | "name": "extraData", 179 | "type": "bytes" 180 | } 181 | ], 182 | "name": "ERC20WithdrawalFinalized", 183 | "type": "event" 184 | }, 185 | { 186 | "anonymous": false, 187 | "inputs": [ 188 | { 189 | "indexed": true, 190 | "internalType": "address", 191 | "name": "from", 192 | "type": "address" 193 | }, 194 | { 195 | "indexed": true, 196 | "internalType": "address", 197 | "name": "to", 198 | "type": "address" 199 | }, 200 | { 201 | "indexed": false, 202 | "internalType": "uint256", 203 | "name": "amount", 204 | "type": "uint256" 205 | }, 206 | { 207 | "indexed": false, 208 | "internalType": "bytes", 209 | "name": "extraData", 210 | "type": "bytes" 211 | } 212 | ], 213 | "name": "ETHBridgeFinalized", 214 | "type": "event" 215 | }, 216 | { 217 | "anonymous": false, 218 | "inputs": [ 219 | { 220 | "indexed": true, 221 | "internalType": "address", 222 | "name": "from", 223 | "type": "address" 224 | }, 225 | { 226 | "indexed": true, 227 | "internalType": "address", 228 | "name": "to", 229 | "type": "address" 230 | }, 231 | { 232 | "indexed": false, 233 | "internalType": "uint256", 234 | "name": "amount", 235 | "type": "uint256" 236 | }, 237 | { 238 | "indexed": false, 239 | "internalType": "bytes", 240 | "name": "extraData", 241 | "type": "bytes" 242 | } 243 | ], 244 | "name": "ETHBridgeInitiated", 245 | "type": "event" 246 | }, 247 | { 248 | "anonymous": false, 249 | "inputs": [ 250 | { 251 | "indexed": true, 252 | "internalType": "address", 253 | "name": "from", 254 | "type": "address" 255 | }, 256 | { 257 | "indexed": true, 258 | "internalType": "address", 259 | "name": "to", 260 | "type": "address" 261 | }, 262 | { 263 | "indexed": false, 264 | "internalType": "uint256", 265 | "name": "amount", 266 | "type": "uint256" 267 | }, 268 | { 269 | "indexed": false, 270 | "internalType": "bytes", 271 | "name": "extraData", 272 | "type": "bytes" 273 | } 274 | ], 275 | "name": "ETHDepositInitiated", 276 | "type": "event" 277 | }, 278 | { 279 | "anonymous": false, 280 | "inputs": [ 281 | { 282 | "indexed": true, 283 | "internalType": "address", 284 | "name": "from", 285 | "type": "address" 286 | }, 287 | { 288 | "indexed": true, 289 | "internalType": "address", 290 | "name": "to", 291 | "type": "address" 292 | }, 293 | { 294 | "indexed": false, 295 | "internalType": "uint256", 296 | "name": "amount", 297 | "type": "uint256" 298 | }, 299 | { 300 | "indexed": false, 301 | "internalType": "bytes", 302 | "name": "extraData", 303 | "type": "bytes" 304 | } 305 | ], 306 | "name": "ETHWithdrawalFinalized", 307 | "type": "event" 308 | }, 309 | { 310 | "inputs": [], 311 | "name": "MESSENGER", 312 | "outputs": [ 313 | { 314 | "internalType": "contract CrossDomainMessenger", 315 | "name": "", 316 | "type": "address" 317 | } 318 | ], 319 | "stateMutability": "view", 320 | "type": "function" 321 | }, 322 | { 323 | "inputs": [], 324 | "name": "OTHER_BRIDGE", 325 | "outputs": [ 326 | { 327 | "internalType": "contract StandardBridge", 328 | "name": "", 329 | "type": "address" 330 | } 331 | ], 332 | "stateMutability": "view", 333 | "type": "function" 334 | }, 335 | { 336 | "inputs": [ 337 | { "internalType": "address", "name": "_localToken", "type": "address" }, 338 | { "internalType": "address", "name": "_remoteToken", "type": "address" }, 339 | { "internalType": "uint256", "name": "_amount", "type": "uint256" }, 340 | { "internalType": "uint32", "name": "_minGasLimit", "type": "uint32" }, 341 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 342 | ], 343 | "name": "bridgeERC20", 344 | "outputs": [], 345 | "stateMutability": "nonpayable", 346 | "type": "function" 347 | }, 348 | { 349 | "inputs": [ 350 | { "internalType": "address", "name": "_localToken", "type": "address" }, 351 | { "internalType": "address", "name": "_remoteToken", "type": "address" }, 352 | { "internalType": "address", "name": "_to", "type": "address" }, 353 | { "internalType": "uint256", "name": "_amount", "type": "uint256" }, 354 | { "internalType": "uint32", "name": "_minGasLimit", "type": "uint32" }, 355 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 356 | ], 357 | "name": "bridgeERC20To", 358 | "outputs": [], 359 | "stateMutability": "nonpayable", 360 | "type": "function" 361 | }, 362 | { 363 | "inputs": [ 364 | { "internalType": "uint32", "name": "_minGasLimit", "type": "uint32" }, 365 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 366 | ], 367 | "name": "bridgeETH", 368 | "outputs": [], 369 | "stateMutability": "payable", 370 | "type": "function" 371 | }, 372 | { 373 | "inputs": [ 374 | { "internalType": "address", "name": "_to", "type": "address" }, 375 | { "internalType": "uint32", "name": "_minGasLimit", "type": "uint32" }, 376 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 377 | ], 378 | "name": "bridgeETHTo", 379 | "outputs": [], 380 | "stateMutability": "payable", 381 | "type": "function" 382 | }, 383 | { 384 | "inputs": [ 385 | { "internalType": "address", "name": "_l1Token", "type": "address" }, 386 | { "internalType": "address", "name": "_l2Token", "type": "address" }, 387 | { "internalType": "uint256", "name": "_amount", "type": "uint256" }, 388 | { "internalType": "uint32", "name": "_minGasLimit", "type": "uint32" }, 389 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 390 | ], 391 | "name": "depositERC20", 392 | "outputs": [], 393 | "stateMutability": "nonpayable", 394 | "type": "function" 395 | }, 396 | { 397 | "inputs": [ 398 | { "internalType": "address", "name": "_l1Token", "type": "address" }, 399 | { "internalType": "address", "name": "_l2Token", "type": "address" }, 400 | { "internalType": "address", "name": "_to", "type": "address" }, 401 | { "internalType": "uint256", "name": "_amount", "type": "uint256" }, 402 | { "internalType": "uint32", "name": "_minGasLimit", "type": "uint32" }, 403 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 404 | ], 405 | "name": "depositERC20To", 406 | "outputs": [], 407 | "stateMutability": "nonpayable", 408 | "type": "function" 409 | }, 410 | { 411 | "inputs": [ 412 | { "internalType": "uint32", "name": "_minGasLimit", "type": "uint32" }, 413 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 414 | ], 415 | "name": "depositETH", 416 | "outputs": [], 417 | "stateMutability": "payable", 418 | "type": "function" 419 | }, 420 | { 421 | "inputs": [ 422 | { "internalType": "address", "name": "_to", "type": "address" }, 423 | { "internalType": "uint32", "name": "_minGasLimit", "type": "uint32" }, 424 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 425 | ], 426 | "name": "depositETHTo", 427 | "outputs": [], 428 | "stateMutability": "payable", 429 | "type": "function" 430 | }, 431 | { 432 | "inputs": [ 433 | { "internalType": "address", "name": "", "type": "address" }, 434 | { "internalType": "address", "name": "", "type": "address" } 435 | ], 436 | "name": "deposits", 437 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 438 | "stateMutability": "view", 439 | "type": "function" 440 | }, 441 | { 442 | "inputs": [ 443 | { "internalType": "address", "name": "_localToken", "type": "address" }, 444 | { "internalType": "address", "name": "_remoteToken", "type": "address" }, 445 | { "internalType": "address", "name": "_from", "type": "address" }, 446 | { "internalType": "address", "name": "_to", "type": "address" }, 447 | { "internalType": "uint256", "name": "_amount", "type": "uint256" }, 448 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 449 | ], 450 | "name": "finalizeBridgeERC20", 451 | "outputs": [], 452 | "stateMutability": "nonpayable", 453 | "type": "function" 454 | }, 455 | { 456 | "inputs": [ 457 | { "internalType": "address", "name": "_from", "type": "address" }, 458 | { "internalType": "address", "name": "_to", "type": "address" }, 459 | { "internalType": "uint256", "name": "_amount", "type": "uint256" }, 460 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 461 | ], 462 | "name": "finalizeBridgeETH", 463 | "outputs": [], 464 | "stateMutability": "payable", 465 | "type": "function" 466 | }, 467 | { 468 | "inputs": [ 469 | { "internalType": "address", "name": "_l1Token", "type": "address" }, 470 | { "internalType": "address", "name": "_l2Token", "type": "address" }, 471 | { "internalType": "address", "name": "_from", "type": "address" }, 472 | { "internalType": "address", "name": "_to", "type": "address" }, 473 | { "internalType": "uint256", "name": "_amount", "type": "uint256" }, 474 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 475 | ], 476 | "name": "finalizeERC20Withdrawal", 477 | "outputs": [], 478 | "stateMutability": "nonpayable", 479 | "type": "function" 480 | }, 481 | { 482 | "inputs": [ 483 | { "internalType": "address", "name": "_from", "type": "address" }, 484 | { "internalType": "address", "name": "_to", "type": "address" }, 485 | { "internalType": "uint256", "name": "_amount", "type": "uint256" }, 486 | { "internalType": "bytes", "name": "_extraData", "type": "bytes" } 487 | ], 488 | "name": "finalizeETHWithdrawal", 489 | "outputs": [], 490 | "stateMutability": "payable", 491 | "type": "function" 492 | }, 493 | { 494 | "inputs": [], 495 | "name": "l2TokenBridge", 496 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }], 497 | "stateMutability": "view", 498 | "type": "function" 499 | }, 500 | { 501 | "inputs": [], 502 | "name": "messenger", 503 | "outputs": [ 504 | { 505 | "internalType": "contract CrossDomainMessenger", 506 | "name": "", 507 | "type": "address" 508 | } 509 | ], 510 | "stateMutability": "view", 511 | "type": "function" 512 | }, 513 | { 514 | "inputs": [], 515 | "name": "version", 516 | "outputs": [{ "internalType": "string", "name": "", "type": "string" }], 517 | "stateMutability": "view", 518 | "type": "function" 519 | }, 520 | { "stateMutability": "payable", "type": "receive" } 521 | ] 522 | -------------------------------------------------------------------------------- /bridge/native/hardhat.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Coinbase Global, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | const { keccak256 } = require('@ethersproject/keccak256'); 18 | const { defaultAbiCoder } = require('@ethersproject/abi'); 19 | const { HashZero } = require('@ethersproject/constants'); 20 | 21 | const { mnemonic, alchemyKey } = require('./secrets.json'); 22 | const l1BridgeAbi = require('./abi/l1standardbridge.json'); 23 | const tokenAbi = require('./abi/erc20.json'); 24 | const l2BridgeAbi = require('./abi/l2standardbridge.json'); 25 | const l2Tol1MessagePasserAbi = require('./abi/l2tol1messagepasser.json'); 26 | const l2OuputOracleAbi = require('./abi/l2OutputOracle.json'); 27 | const optimismPortalAbi = require('./abi/optimismPortal.json'); 28 | 29 | require('@nomicfoundation/hardhat-toolbox'); 30 | require('@nomicfoundation/hardhat-ethers'); 31 | 32 | const l2ExplorerApi = 'https://base-goerli.blockscout.com/api'; 33 | const l1StandardBridge = '0xfA6D8Ee5BE770F84FC001D098C4bD604Fe01284a'; 34 | const l2StandardBridge = '0x4200000000000000000000000000000000000010'; 35 | const l2ToL1MessagePasser = '0x4200000000000000000000000000000000000016'; 36 | const l2OutputOracle = '0x2A35891ff30313CcFa6CE88dcf3858bb075A2298'; 37 | const optimismPortal = '0xe93c8cD0D409341205A592f8c4Ac1A5fe5585cfA'; 38 | 39 | const defaultGasAmount = '100000'; 40 | const emptyData = '0x'; 41 | 42 | const getBaseWallet = () => { 43 | // Create a wallet from the mnemonic 44 | const wallet = ethers.Wallet.fromPhrase(mnemonic); 45 | 46 | // Create a provider using the wallet 47 | const provider = new ethers.JsonRpcProvider( 48 | hreConfig.networks['base-goerli'].url, 49 | ); 50 | 51 | // Set the provider for the wallet 52 | const signer = wallet.connect(provider); 53 | 54 | return signer; 55 | }; 56 | 57 | const getL1Wallet = () => { 58 | // Create a wallet from the mnemonic 59 | const wallet = ethers.Wallet.fromPhrase(mnemonic); 60 | 61 | // Create a provider using the wallet 62 | const provider = new ethers.JsonRpcProvider(hreConfig.networks['goerli'].url); 63 | 64 | // Set the provider for the wallet 65 | const signer = wallet.connect(provider); 66 | 67 | return signer; 68 | }; 69 | 70 | const getPortalContract = (signer) => { 71 | const portalContract = new ethers.Contract( 72 | optimismPortal, 73 | optimismPortalAbi, 74 | signer, 75 | ); 76 | return portalContract; 77 | }; 78 | 79 | const getOracleContract = (signer) => { 80 | const oracleContract = new ethers.Contract( 81 | l2OutputOracle, 82 | l2OuputOracleAbi, 83 | signer, 84 | ); 85 | return oracleContract; 86 | }; 87 | 88 | const getMessageContract = (signer) => { 89 | const messageContract = new ethers.Contract( 90 | l2ToL1MessagePasser, 91 | l2Tol1MessagePasserAbi, 92 | signer, 93 | ); 94 | return messageContract; 95 | }; 96 | 97 | const getL1StandardBridgeContract = (signer) => { 98 | const bridgeContract = new ethers.Contract( 99 | l1StandardBridge, 100 | l1BridgeAbi, 101 | signer, 102 | ); 103 | return bridgeContract; 104 | }; 105 | 106 | const getL2StandardBridgeContract = (signer) => { 107 | const bridgeContract = new ethers.Contract( 108 | l2StandardBridge, 109 | l2BridgeAbi, 110 | signer, 111 | ); 112 | return bridgeContract; 113 | }; 114 | 115 | const getTokenContract = (signer, address) => { 116 | const tokenContract = new ethers.Contract(address, tokenAbi, signer); 117 | return tokenContract; 118 | }; 119 | 120 | const makeStateTrieProof = async (provider, blockNumber, address, slot) => { 121 | const proof = await provider.send('eth_getProof', [ 122 | address, 123 | [slot], 124 | blockNumber, 125 | ]); 126 | 127 | return { 128 | accountProof: proof.accountProof, 129 | storageProof: proof.storageProof[0].proof, 130 | storageValue: BigInt(proof.storageProof[0].value), 131 | storageRoot: proof.storageHash, 132 | }; 133 | }; 134 | 135 | const hashWithdrawal = (withdrawalMessage) => { 136 | const types = [ 137 | 'uint256', 138 | 'address', 139 | 'address', 140 | 'uint256', 141 | 'uint256', 142 | 'bytes', 143 | ]; 144 | const encoded = defaultAbiCoder.encode(types, [ 145 | withdrawalMessage.nonce, 146 | withdrawalMessage.sender, 147 | withdrawalMessage.target, 148 | withdrawalMessage.value, 149 | withdrawalMessage.gasLimit, 150 | withdrawalMessage.data, 151 | ]); 152 | return keccak256(encoded); 153 | }; 154 | 155 | const getWithdrawalMessage = async (messageContract, withdrawal, isToken) => { 156 | let messageLog = withdrawal.logs.find((log) => { 157 | if (log.address === l2ToL1MessagePasser) { 158 | const parsed = messageContract.interface.parseLog(log); 159 | console.log('parsed', parsed); 160 | return parsed.name === 'MessagePassed'; 161 | } 162 | return false; 163 | }); 164 | console.log('messageLog', messageLog); 165 | 166 | if (!messageLog) { 167 | messageLog = withdrawal.logs[0]; 168 | } 169 | const parsedLog = messageContract.interface.parseLog(messageLog); 170 | 171 | const withdrawalMessage = { 172 | nonce: parsedLog.args.nonce, 173 | sender: parsedLog.args.sender, 174 | target: parsedLog.args.target, 175 | value: parsedLog.args.value, 176 | gasLimit: parsedLog.args.gasLimit, 177 | data: parsedLog.args.data, 178 | }; 179 | console.log('withdrawalMessage', withdrawalMessage); 180 | return withdrawalMessage; 181 | }; 182 | 183 | const fetchTransactions = async (address) => { 184 | const params = { 185 | address, 186 | action: 'txlist', 187 | module: 'account', 188 | filterby: 'from', 189 | startblock: '0', 190 | }; 191 | const searchParams = new URLSearchParams(params).toString(); 192 | const url = new URL(l2ExplorerApi); 193 | url.search = searchParams; 194 | const transactions = await fetch(url, { 195 | headers: { 196 | Accept: 'application/json', 197 | }, 198 | }); 199 | const data = await transactions.json(); 200 | return data; 201 | }; 202 | 203 | task('balance', "Prints an account's balance").setAction(async (taskArgs) => { 204 | const signer = await ethers.provider.getSigner(); 205 | const balance = await ethers.provider.getBalance(await signer.getAddress()); 206 | 207 | console.log(ethers.formatEther(balance), 'ETH'); 208 | }); 209 | 210 | task('bridge', 'Bridges ETH to base-goerli') 211 | .addParam('amount', 'The amount to bridge') 212 | .setAction(async (taskArgs) => { 213 | const signer = await ethers.provider.getSigner(); 214 | 215 | const bridgeContract = getL1StandardBridgeContract(signer); 216 | 217 | const sender = await bridgeContract.l2TokenBridge(); 218 | console.log('sender', sender); 219 | 220 | const fmtAmount = ethers.parseUnits(taskArgs.amount); 221 | console.log('fmtAmount', fmtAmount); 222 | 223 | try { 224 | const bridgeResult = await bridgeContract.bridgeETH( 225 | defaultGasAmount, 226 | emptyData, 227 | { 228 | value: fmtAmount, 229 | }, 230 | ); 231 | console.log('bridgeResult', bridgeResult); 232 | const transactionReceipt = await bridgeResult.wait(); 233 | console.log('transactionReceipt', transactionReceipt); 234 | } catch (e) { 235 | console.log('bridgeResult error', e); 236 | } 237 | }); 238 | 239 | task('bridgeToken', 'Bridges erc20 token to base-goerli') 240 | .addParam('amount', 'The amount to bridge') 241 | .addParam('l1token', 'The token address on goerli') 242 | .addParam('l2token', 'The token address on base-goerli') 243 | .setAction(async (taskArgs) => { 244 | const signer = await ethers.provider.getSigner(); 245 | 246 | const bridgeContract = getL1StandardBridgeContract(signer); 247 | 248 | const sender = await bridgeContract.l2TokenBridge(); 249 | console.log('sender', sender); 250 | 251 | const fmtAmount = ethers.parseUnits(taskArgs.amount); 252 | console.log('fmtAmount', fmtAmount); 253 | 254 | const tokenContract = getTokenContract(signer, taskArgs.l1token); 255 | 256 | try { 257 | const allowance = await tokenContract.allowance( 258 | await signer.getAddress(), 259 | l1StandardBridge, 260 | ); 261 | if (allowance < fmtAmount) { 262 | console.log('approve bridge to access token'); 263 | const approveResult = await tokenContract.approve( 264 | l1StandardBridge, 265 | fmtAmount, 266 | ); 267 | console.log('approve result', approveResult); 268 | } else { 269 | console.log('token is approved to deposit'); 270 | } 271 | 272 | const bridgeResult = await bridgeContract.depositERC20( 273 | taskArgs.l1token, 274 | taskArgs.l2token, 275 | fmtAmount, 276 | defaultGasAmount, 277 | emptyData, 278 | ); 279 | console.log('bridge token result', bridgeResult); 280 | const transactionReceipt = await bridgeResult.wait(); 281 | console.log('token transaction receipt', transactionReceipt); 282 | } catch (e) { 283 | console.log('bridge token result error', e); 284 | } 285 | }); 286 | 287 | task( 288 | 'withdraw', 289 | 'Initiates a native token withdrawal from base-goerli to goerli', 290 | ) 291 | .addParam('amount', 'The amount to bridge') 292 | .setAction(async (taskArgs) => { 293 | const signer = await getBaseWallet(); 294 | 295 | const messageContract = getMessageContract(signer); 296 | 297 | const nonce = await messageContract.messageNonce(); 298 | console.log('messageNonce', nonce); 299 | 300 | const fmtAmount = ethers.parseUnits(taskArgs.amount); 301 | console.log('fmtAmount', fmtAmount); 302 | 303 | try { 304 | const bridgeResult = await messageContract.initiateWithdrawal( 305 | signer.address, 306 | defaultGasAmount, 307 | emptyData, 308 | { value: fmtAmount }, 309 | ); 310 | console.log('withdrawal result', bridgeResult); 311 | const transactionReceipt = await bridgeResult.wait(); 312 | console.log('withdrawal transaction receipt', transactionReceipt); 313 | } catch (e) { 314 | console.log('withdrawal error', e); 315 | } 316 | }); 317 | 318 | task( 319 | 'withdrawToken', 320 | 'Initiates a native token withdrawal from base-goerli to goerli', 321 | ) 322 | .addParam('amount', 'The amount to bridge') 323 | .addParam('token', 'The token address on base-goerli') 324 | .setAction(async (taskArgs) => { 325 | const signer = await getBaseWallet(); 326 | 327 | const l2StandardBridgeContract = getL2StandardBridgeContract(signer); 328 | 329 | const fmtAmount = ethers.parseUnits(taskArgs.amount); 330 | console.log('fmtAmount', fmtAmount); 331 | 332 | try { 333 | const bridgeResult = await l2StandardBridgeContract.withdraw( 334 | taskArgs.token, 335 | fmtAmount, 336 | defaultGasAmount, 337 | '0x01', 338 | ); 339 | console.log('withdrawal result', bridgeResult); 340 | const transactionReceipt = await bridgeResult.wait(); 341 | console.log('withdrawal transaction receipt', transactionReceipt); 342 | } catch (e) { 343 | console.log('withdrawal error', e); 344 | } 345 | }); 346 | 347 | task( 348 | 'proveWithdrawal', 349 | 'Proves a native token withdrawal from base-goerli to goerli', 350 | ) 351 | .addParam('tx', 'The transaction hash of the withdrawal') 352 | .setAction(async (taskArgs) => { 353 | const signer = await getBaseWallet(); 354 | 355 | const l1Signer = await getL1Wallet(); 356 | 357 | const oracleContract = getOracleContract(l1Signer); 358 | 359 | const messageContract = getMessageContract(signer); 360 | 361 | const portalContract = getPortalContract(l1Signer); 362 | 363 | const withdrawal = await signer.provider.getTransactionReceipt(taskArgs.tx); 364 | console.log('withdrawal receipt', withdrawal.blockNumber, withdrawal); 365 | 366 | const l2OutputIdx = await oracleContract.getL2OutputIndexAfter( 367 | withdrawal.blockNumber, 368 | ); 369 | console.log('l2OutputIdx', l2OutputIdx); 370 | 371 | const l2Output = await oracleContract.getL2Output(l2OutputIdx); 372 | console.log('l2Output', l2Output); 373 | 374 | const withdrawalMessage = await getWithdrawalMessage( 375 | messageContract, 376 | withdrawal, 377 | ); 378 | 379 | const hashedWithdrawal = hashWithdrawal(withdrawalMessage); 380 | 381 | const messageSlot = keccak256( 382 | defaultAbiCoder.encode( 383 | ['bytes32', 'uint256'], 384 | [hashedWithdrawal, HashZero], 385 | ), 386 | ); 387 | 388 | const l2BlockNumber = '0x' + BigInt(l2Output[2]).toString(16); 389 | 390 | const proof = await makeStateTrieProof( 391 | signer.provider, 392 | l2BlockNumber, 393 | l2ToL1MessagePasser, 394 | messageSlot, 395 | ); 396 | console.log('proof', proof); 397 | 398 | const block = await signer.provider.send('eth_getBlockByNumber', [ 399 | l2BlockNumber, 400 | false, 401 | ]); 402 | console.log('block', block); 403 | 404 | const outputProof = { 405 | version: HashZero, 406 | stateRoot: block.stateRoot, 407 | messagePasserStorageRoot: proof.storageRoot, 408 | latestBlockhash: block.hash, 409 | }; 410 | console.log('outputProof', outputProof); 411 | 412 | try { 413 | const proving = await portalContract.proveWithdrawalTransaction( 414 | withdrawalMessage, 415 | l2OutputIdx, 416 | outputProof, 417 | proof.storageProof, 418 | ); 419 | console.log('proving', proving); 420 | const result = await proving.wait(); 421 | console.log('proving result', result); 422 | } catch (e) { 423 | console.log('withdrawal error', e); 424 | } 425 | }); 426 | 427 | task( 428 | 'finalizeWithdrawal', 429 | 'Finalizes a native token withdrawal from base-goerli to goerli', 430 | ) 431 | .addParam('tx', 'The transaction hash of the withdrawal') 432 | .setAction(async (taskArgs) => { 433 | const signer = await getBaseWallet(); 434 | 435 | const l1Signer = await getL1Wallet(); 436 | 437 | const portalContract = getPortalContract(l1Signer); 438 | 439 | const messageContract = getMessageContract(signer); 440 | 441 | const withdrawal = await signer.provider.getTransactionReceipt(taskArgs.tx); 442 | console.log('withdrawal receipt', withdrawal.blockNumber, withdrawal); 443 | 444 | const msg = await getWithdrawalMessage(messageContract, withdrawal); 445 | console.log('msg', msg); 446 | try { 447 | const finalizing = 448 | await portalContract.finalizeWithdrawalTransaction(msg); 449 | console.log('finalizing', finalizing); 450 | const result = await finalizing.wait(); 451 | console.log('finalizing result', result); 452 | } catch (e) { 453 | console.log('finalize error', e); 454 | } 455 | }); 456 | 457 | task('fetchWithdrawals', 'Fetchs all withdrawals') 458 | .addFlag('full', 'Show the full address') 459 | .setAction(async (taskArgs) => { 460 | const signer = await getBaseWallet(); 461 | 462 | const l1Signer = await getL1Wallet(); 463 | 464 | const portalContract = getPortalContract(l1Signer); 465 | 466 | const messageContract = getMessageContract(signer); 467 | 468 | const oracleContract = getOracleContract(l1Signer); 469 | 470 | const l2StandardBridgeContract = getL2StandardBridgeContract(signer); 471 | 472 | try { 473 | const data = await fetchTransactions(await signer.getAddress()); 474 | const withdrawals = []; 475 | for (let i = 0; i < data.result.length; i++) { 476 | const tx = data.result[i]; 477 | console.log(i, tx); 478 | if (tx.isError === '1') continue; 479 | if (tx.to === l2ToL1MessagePasser && tx.value !== '0') 480 | withdrawals.push(tx); 481 | if (tx.to === optimismPortal && tx.value !== '0') withdrawals.push(tx); 482 | if (tx.to === l2StandardBridge) { 483 | const functionName = l2StandardBridgeContract.interface.getFunction( 484 | tx.input.slice(0, 10), 485 | ).name; 486 | console.log('functionName', functionName); 487 | if (functionName === 'withdraw') { 488 | const decodedWithdrawData = 489 | l2StandardBridgeContract.interface.decodeFunctionData( 490 | tx.input.slice(0, 10), 491 | tx.input, 492 | ); 493 | tx.value = decodedWithdrawData[1].toString(); 494 | 495 | const tokenDetails = getTokenContract( 496 | signer, 497 | decodedWithdrawData[0], 498 | ); 499 | tx.symbol = await tokenDetails.symbol(); 500 | 501 | withdrawals.push(tx); 502 | } 503 | } 504 | } 505 | console.log('raw transactions', withdrawals); 506 | 507 | const latestBlockNumber = await oracleContract.latestBlockNumber(); 508 | const finalizationPeriod = 509 | await oracleContract.FINALIZATION_PERIOD_SECONDS(); 510 | for (let i = 0; i < withdrawals.length; i++) { 511 | const withdrawal = withdrawals[i]; 512 | const receipt = await signer.provider.getTransactionReceipt( 513 | withdrawal.hash, 514 | ); 515 | console.log('receipt', receipt); 516 | const wm = await getWithdrawalMessage(messageContract, receipt); 517 | const hash = hashWithdrawal(wm); 518 | const isFinalized = await portalContract.finalizedWithdrawals(hash); 519 | withdrawal.isFinalized = isFinalized; 520 | 521 | const rawProof = await portalContract.provenWithdrawals(hash); 522 | withdrawal.rawProof = rawProof; 523 | const isProven = rawProof[0] !== HashZero; 524 | withdrawal.isReadyToFinalize = 525 | Math.floor(Date.now() / 1000) > rawProof[1] + finalizationPeriod && 526 | !isFinalized && 527 | isProven; 528 | withdrawal.isProven = isProven; 529 | withdrawal.isReadyToProve = 530 | latestBlockNumber >= receipt.blockNumber && !isFinalized && !isProven; 531 | } 532 | 533 | console.log('withdrawals', withdrawals); 534 | const sorted = withdrawals.sort((a, b) => { 535 | return a.timeStamp > b.timeStamp; 536 | }); 537 | const withdrawalTable = sorted.map((withdrawal) => ({ 538 | hash: taskArgs.full 539 | ? withdrawal.hash 540 | : withdrawal.hash.substring(0, 6) + 541 | '...' + 542 | withdrawal.hash.substring(withdrawal.hash.length - 6), 543 | symbol: withdrawal.symbol || 'ETH', 544 | value: withdrawal.value, 545 | isReadyToProve: withdrawal.isReadyToProve, 546 | isProven: withdrawal.isProven, 547 | isReadyToFinalize: withdrawal.isReadyToFinalize, 548 | isFinalized: withdrawal.isFinalized, 549 | })); 550 | console.table(withdrawalTable); 551 | } catch (e) { 552 | console.log('fetch withdrawals error', e); 553 | } 554 | }); 555 | 556 | /** @type import('hardhat/config').HardhatUserConfig */ 557 | const hreConfig = { 558 | solidity: '0.8.17', 559 | defaultNetwork: 'goerli', 560 | networks: { 561 | hardhat: {}, 562 | goerli: { 563 | url: 'https://eth-goerli.g.alchemy.com/v2/' + alchemyKey, 564 | accounts: { 565 | mnemonic, 566 | }, 567 | gasPrice: 1000000000, 568 | }, 569 | 'base-goerli': { 570 | url: 'https://goerli.base.org', 571 | accounts: { 572 | mnemonic, 573 | }, 574 | gasPrice: 1000000000, 575 | }, 576 | }, 577 | }; 578 | module.exports = hreConfig; 579 | -------------------------------------------------------------------------------- /based/THIRD-PARTY-NOTICES: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | eth-diamond-purple.png 4 | 5 | GNU LESSER GENERAL PUBLIC LICENSE 6 | Version 3, 29 June 2007 7 | 8 | Copyright (C) 2007 Free Software Foundation, Inc. 9 | Everyone is permitted to copy and distribute verbatim copies 10 | of this license document, but changing it is not allowed. 11 | 12 | This version of the GNU Lesser General Public License incorporates 13 | the terms and conditions of version 3 of the GNU General Public 14 | License, supplemented by the additional permissions listed below. 15 | 16 | 0. Additional Definitions. 17 | 18 | As used herein, "this License" refers to version 3 of the GNU Lesser 19 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 20 | General Public License. 21 | 22 | "The Library" refers to a covered work governed by this License, 23 | other than an Application or a Combined Work as defined below. 24 | 25 | An "Application" is any work that makes use of an interface provided 26 | by the Library, but which is not otherwise based on the Library. 27 | Defining a subclass of a class defined by the Library is deemed a mode 28 | of using an interface provided by the Library. 29 | 30 | A "Combined Work" is a work produced by combining or linking an 31 | Application with the Library. The particular version of the Library 32 | with which the Combined Work was made is also called the "Linked 33 | Version". 34 | 35 | The "Minimal Corresponding Source" for a Combined Work means the 36 | Corresponding Source for the Combined Work, excluding any source code 37 | for portions of the Combined Work that, considered in isolation, are 38 | based on the Application, and not on the Linked Version. 39 | 40 | The "Corresponding Application Code" for a Combined Work means the 41 | object code and/or source code for the Application, including any data 42 | and utility programs needed for reproducing the Combined Work from the 43 | Application, but excluding the System Libraries of the Combined Work. 44 | 45 | 1. Exception to Section 3 of the GNU GPL. 46 | 47 | You may convey a covered work under sections 3 and 4 of this License 48 | without being bound by section 3 of the GNU GPL. 49 | 50 | 2. Conveying Modified Versions. 51 | 52 | If you modify a copy of the Library, and, in your modifications, a 53 | facility refers to a function or data to be supplied by an Application 54 | that uses the facility (other than as an argument passed when the 55 | facility is invoked), then you may convey a copy of the modified 56 | version: 57 | 58 | a) under this License, provided that you make a good faith effort to 59 | ensure that, in the event an Application does not supply the 60 | function or data, the facility still operates, and performs 61 | whatever part of its purpose remains meaningful, or 62 | 63 | b) under the GNU GPL, with none of the additional permissions of 64 | this License applicable to that copy. 65 | 66 | 3. Object Code Incorporating Material from Library Header Files. 67 | 68 | The object code form of an Application may incorporate material from 69 | a header file that is part of the Library. You may convey such object 70 | code under terms of your choice, provided that, if the incorporated 71 | material is not limited to numerical parameters, data structure 72 | layouts and accessors, or small macros, inline functions and templates 73 | (ten or fewer lines in length), you do both of the following: 74 | 75 | a) Give prominent notice with each copy of the object code that the 76 | Library is used in it and that the Library and its use are 77 | covered by this License. 78 | 79 | b) Accompany the object code with a copy of the GNU GPL and this license 80 | document. 81 | 82 | 4. Combined Works. 83 | 84 | You may convey a Combined Work under terms of your choice that, 85 | taken together, effectively do not restrict modification of the 86 | portions of the Library contained in the Combined Work and reverse 87 | engineering for debugging such modifications, if you also do each of 88 | the following: 89 | 90 | a) Give prominent notice with each copy of the Combined Work that 91 | the Library is used in it and that the Library and its use are 92 | covered by this License. 93 | 94 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 95 | document. 96 | 97 | c) For a Combined Work that displays copyright notices during 98 | execution, include the copyright notice for the Library among 99 | these notices, as well as a reference directing the user to the 100 | copies of the GNU GPL and this license document. 101 | 102 | d) Do one of the following: 103 | 104 | 0) Convey the Minimal Corresponding Source under the terms of this 105 | License, and the Corresponding Application Code in a form 106 | suitable for, and under terms that permit, the user to 107 | recombine or relink the Application with a modified version of 108 | the Linked Version to produce a modified Combined Work, in the 109 | manner specified by section 6 of the GNU GPL for conveying 110 | Corresponding Source. 111 | 112 | 1) Use a suitable shared library mechanism for linking with the 113 | Library. A suitable mechanism is one that (a) uses at run time 114 | a copy of the Library already present on the user's computer 115 | system, and (b) will operate properly with a modified version 116 | of the Library that is interface-compatible with the Linked 117 | Version. 118 | 119 | e) Provide Installation Information, but only if you would otherwise 120 | be required to provide such information under section 6 of the 121 | GNU GPL, and only to the extent that such information is 122 | necessary to install and execute a modified version of the 123 | Combined Work produced by recombining or relinking the 124 | Application with a modified version of the Linked Version. (If 125 | you use option 4d0, the Installation Information must accompany 126 | the Minimal Corresponding Source and Corresponding Application 127 | Code. If you use option 4d1, you must provide the Installation 128 | Information in the manner specified by section 6 of the GNU GPL 129 | for conveying Corresponding Source.) 130 | 131 | 5. Combined Libraries. 132 | 133 | You may place library facilities that are a work based on the 134 | Library side by side in a single library together with other library 135 | facilities that are not Applications and are not covered by this 136 | License, and convey such a combined library under terms of your 137 | choice, if you do both of the following: 138 | 139 | a) Accompany the combined library with a copy of the same work based 140 | on the Library, uncombined with any other library facilities, 141 | conveyed under the terms of this License. 142 | 143 | b) Give prominent notice with the combined library that part of it 144 | is a work based on the Library, and explaining where to find the 145 | accompanying uncombined form of the same work. 146 | 147 | 6. Revised Versions of the GNU Lesser General Public License. 148 | 149 | The Free Software Foundation may publish revised and/or new versions 150 | of the GNU Lesser General Public License from time to time. Such new 151 | versions will be similar in spirit to the present version, but may 152 | differ in detail to address new problems or concerns. 153 | 154 | Each version is given a distinguishing version number. If the 155 | Library as you received it specifies that a certain numbered version 156 | of the GNU Lesser General Public License "or any later version" 157 | applies to it, you have the option of following the terms and 158 | conditions either of that published version or of any later version 159 | published by the Free Software Foundation. If the Library as you 160 | received it does not specify a version number of the GNU Lesser 161 | General Public License, you may choose any version of the GNU Lesser 162 | General Public License ever published by the Free Software Foundation. 163 | 164 | If the Library as you received it specifies that a proxy can decide 165 | whether future versions of the GNU Lesser General Public License shall 166 | apply, that proxy's public statement of acceptance of any version is 167 | permanent authorization for you to choose that version for the 168 | Library. 169 | 170 | --- 171 | 172 | solidity/logo.svg 173 | 174 | Attribution 4.0 International 175 | 176 | ======================================================================= 177 | 178 | Creative Commons Corporation ("Creative Commons") is not a law firm and 179 | does not provide legal services or legal advice. Distribution of 180 | Creative Commons public licenses does not create a lawyer-client or 181 | other relationship. Creative Commons makes its licenses and related 182 | information available on an "as-is" basis. Creative Commons gives no 183 | warranties regarding its licenses, any material licensed under their 184 | terms and conditions, or any related information. Creative Commons 185 | disclaims all liability for damages resulting from their use to the 186 | fullest extent possible. 187 | 188 | Using Creative Commons Public Licenses 189 | 190 | Creative Commons public licenses provide a standard set of terms and 191 | conditions that creators and other rights holders may use to share 192 | original works of authorship and other material subject to copyright 193 | and certain other rights specified in the public license below. The 194 | following considerations are for informational purposes only, are not 195 | exhaustive, and do not form part of our licenses. 196 | 197 | Considerations for licensors: Our public licenses are 198 | intended for use by those authorized to give the public 199 | permission to use material in ways otherwise restricted by 200 | copyright and certain other rights. Our licenses are 201 | irrevocable. Licensors should read and understand the terms 202 | and conditions of the license they choose before applying it. 203 | Licensors should also secure all rights necessary before 204 | applying our licenses so that the public can reuse the 205 | material as expected. Licensors should clearly mark any 206 | material not subject to the license. This includes other CC- 207 | licensed material, or material used under an exception or 208 | limitation to copyright. More considerations for licensors: 209 | wiki.creativecommons.org/Considerations_for_licensors 210 | 211 | Considerations for the public: By using one of our public 212 | licenses, a licensor grants the public permission to use the 213 | licensed material under specified terms and conditions. If 214 | the licensor's permission is not necessary for any reason--for 215 | example, because of any applicable exception or limitation to 216 | copyright--then that use is not regulated by the license. Our 217 | licenses grant only permissions under copyright and certain 218 | other rights that a licensor has authority to grant. Use of 219 | the licensed material may still be restricted for other 220 | reasons, including because others have copyright or other 221 | rights in the material. A licensor may make special requests, 222 | such as asking that all changes be marked or described. 223 | Although not required by our licenses, you are encouraged to 224 | respect those requests where reasonable. More considerations 225 | for the public: 226 | wiki.creativecommons.org/Considerations_for_licensees 227 | 228 | ======================================================================= 229 | 230 | Creative Commons Attribution 4.0 International Public License 231 | 232 | By exercising the Licensed Rights (defined below), You accept and agree 233 | to be bound by the terms and conditions of this Creative Commons 234 | Attribution 4.0 International Public License ("Public License"). To the 235 | extent this Public License may be interpreted as a contract, You are 236 | granted the Licensed Rights in consideration of Your acceptance of 237 | these terms and conditions, and the Licensor grants You such rights in 238 | consideration of benefits the Licensor receives from making the 239 | Licensed Material available under these terms and conditions. 240 | 241 | Section 1 -- Definitions. 242 | 243 | a. Adapted Material means material subject to Copyright and Similar 244 | Rights that is derived from or based upon the Licensed Material 245 | and in which the Licensed Material is translated, altered, 246 | arranged, transformed, or otherwise modified in a manner requiring 247 | permission under the Copyright and Similar Rights held by the 248 | Licensor. For purposes of this Public License, where the Licensed 249 | Material is a musical work, performance, or sound recording, 250 | Adapted Material is always produced where the Licensed Material is 251 | synched in timed relation with a moving image. 252 | 253 | b. Adapter's License means the license You apply to Your Copyright 254 | and Similar Rights in Your contributions to Adapted Material in 255 | accordance with the terms and conditions of this Public License. 256 | 257 | c. Copyright and Similar Rights means copyright and/or similar rights 258 | closely related to copyright including, without limitation, 259 | performance, broadcast, sound recording, and Sui Generis Database 260 | Rights, without regard to how the rights are labeled or 261 | categorized. For purposes of this Public License, the rights 262 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 263 | Rights. 264 | 265 | d. Effective Technological Measures means those measures that, in the 266 | absence of proper authority, may not be circumvented under laws 267 | fulfilling obligations under Article 11 of the WIPO Copyright 268 | Treaty adopted on December 20, 1996, and/or similar international 269 | agreements. 270 | 271 | e. Exceptions and Limitations means fair use, fair dealing, and/or 272 | any other exception or limitation to Copyright and Similar Rights 273 | that applies to Your use of the Licensed Material. 274 | 275 | f. Licensed Material means the artistic or literary work, database, 276 | or other material to which the Licensor applied this Public 277 | License. 278 | 279 | g. Licensed Rights means the rights granted to You subject to the 280 | terms and conditions of this Public License, which are limited to 281 | all Copyright and Similar Rights that apply to Your use of the 282 | Licensed Material and that the Licensor has authority to license. 283 | 284 | h. Licensor means the individual(s) or entity(ies) granting rights 285 | under this Public License. 286 | 287 | i. Share means to provide material to the public by any means or 288 | process that requires permission under the Licensed Rights, such 289 | as reproduction, public display, public performance, distribution, 290 | dissemination, communication, or importation, and to make material 291 | available to the public including in ways that members of the 292 | public may access the material from a place and at a time 293 | individually chosen by them. 294 | 295 | j. Sui Generis Database Rights means rights other than copyright 296 | resulting from Directive 96/9/EC of the European Parliament and of 297 | the Council of 11 March 1996 on the legal protection of databases, 298 | as amended and/or succeeded, as well as other essentially 299 | equivalent rights anywhere in the world. 300 | 301 | k. You means the individual or entity exercising the Licensed Rights 302 | under this Public License. Your has a corresponding meaning. 303 | 304 | Section 2 -- Scope. 305 | 306 | a. License grant. 307 | 308 | 1. Subject to the terms and conditions of this Public License, 309 | the Licensor hereby grants You a worldwide, royalty-free, 310 | non-sublicensable, non-exclusive, irrevocable license to 311 | exercise the Licensed Rights in the Licensed Material to: 312 | 313 | a. reproduce and Share the Licensed Material, in whole or 314 | in part; and 315 | 316 | b. produce, reproduce, and Share Adapted Material. 317 | 318 | 2. Exceptions and Limitations. For the avoidance of doubt, where 319 | Exceptions and Limitations apply to Your use, this Public 320 | License does not apply, and You do not need to comply with 321 | its terms and conditions. 322 | 323 | 3. Term. The term of this Public License is specified in Section 324 | 6(a). 325 | 326 | 4. Media and formats; technical modifications allowed. The 327 | Licensor authorizes You to exercise the Licensed Rights in 328 | all media and formats whether now known or hereafter created, 329 | and to make technical modifications necessary to do so. The 330 | Licensor waives and/or agrees not to assert any right or 331 | authority to forbid You from making technical modifications 332 | necessary to exercise the Licensed Rights, including 333 | technical modifications necessary to circumvent Effective 334 | Technological Measures. For purposes of this Public License, 335 | simply making modifications authorized by this Section 2(a) 336 | (4) never produces Adapted Material. 337 | 338 | 5. Downstream recipients. 339 | 340 | a. Offer from the Licensor -- Licensed Material. Every 341 | recipient of the Licensed Material automatically 342 | receives an offer from the Licensor to exercise the 343 | Licensed Rights under the terms and conditions of this 344 | Public License. 345 | 346 | b. No downstream restrictions. You may not offer or impose 347 | any additional or different terms or conditions on, or 348 | apply any Effective Technological Measures to, the 349 | Licensed Material if doing so restricts exercise of the 350 | Licensed Rights by any recipient of the Licensed 351 | Material. 352 | 353 | 6. No endorsement. Nothing in this Public License constitutes or 354 | may be construed as permission to assert or imply that You 355 | are, or that Your use of the Licensed Material is, connected 356 | with, or sponsored, endorsed, or granted official status by, 357 | the Licensor or others designated to receive attribution as 358 | provided in Section 3(a)(1)(A)(i). 359 | 360 | b. Other rights. 361 | 362 | 1. Moral rights, such as the right of integrity, are not 363 | licensed under this Public License, nor are publicity, 364 | privacy, and/or other similar personality rights; however, to 365 | the extent possible, the Licensor waives and/or agrees not to 366 | assert any such rights held by the Licensor to the limited 367 | extent necessary to allow You to exercise the Licensed 368 | Rights, but not otherwise. 369 | 370 | 2. Patent and trademark rights are not licensed under this 371 | Public License. 372 | 373 | 3. To the extent possible, the Licensor waives any right to 374 | collect royalties from You for the exercise of the Licensed 375 | Rights, whether directly or through a collecting society 376 | under any voluntary or waivable statutory or compulsory 377 | licensing scheme. In all other cases the Licensor expressly 378 | reserves any right to collect such royalties. 379 | 380 | Section 3 -- License Conditions. 381 | 382 | Your exercise of the Licensed Rights is expressly made subject to the 383 | following conditions. 384 | 385 | a. Attribution. 386 | 387 | 1. If You Share the Licensed Material (including in modified 388 | form), You must: 389 | 390 | a. retain the following if it is supplied by the Licensor 391 | with the Licensed Material: 392 | 393 | i. identification of the creator(s) of the Licensed 394 | Material and any others designated to receive 395 | attribution, in any reasonable manner requested by 396 | the Licensor (including by pseudonym if 397 | designated); 398 | 399 | ii. a copyright notice; 400 | 401 | iii. a notice that refers to this Public License; 402 | 403 | iv. a notice that refers to the disclaimer of 404 | warranties; 405 | 406 | v. a URI or hyperlink to the Licensed Material to the 407 | extent reasonably practicable; 408 | 409 | b. indicate if You modified the Licensed Material and 410 | retain an indication of any previous modifications; and 411 | 412 | c. indicate the Licensed Material is licensed under this 413 | Public License, and include the text of, or the URI or 414 | hyperlink to, this Public License. 415 | 416 | 2. You may satisfy the conditions in Section 3(a)(1) in any 417 | reasonable manner based on the medium, means, and context in 418 | which You Share the Licensed Material. For example, it may be 419 | reasonable to satisfy the conditions by providing a URI or 420 | hyperlink to a resource that includes the required 421 | information. 422 | 423 | 3. If requested by the Licensor, You must remove any of the 424 | information required by Section 3(a)(1)(A) to the extent 425 | reasonably practicable. 426 | 427 | 4. If You Share Adapted Material You produce, the Adapter's 428 | License You apply must not prevent recipients of the Adapted 429 | Material from complying with this Public License. 430 | 431 | Section 4 -- Sui Generis Database Rights. 432 | 433 | Where the Licensed Rights include Sui Generis Database Rights that 434 | apply to Your use of the Licensed Material: 435 | 436 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 437 | to extract, reuse, reproduce, and Share all or a substantial 438 | portion of the contents of the database; 439 | 440 | b. if You include all or a substantial portion of the database 441 | contents in a database in which You have Sui Generis Database 442 | Rights, then the database in which You have Sui Generis Database 443 | Rights (but not its individual contents) is Adapted Material; and 444 | 445 | c. You must comply with the conditions in Section 3(a) if You Share 446 | all or a substantial portion of the contents of the database. 447 | 448 | For the avoidance of doubt, this Section 4 supplements and does not 449 | replace Your obligations under this Public License where the Licensed 450 | Rights include other Copyright and Similar Rights. 451 | 452 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 453 | 454 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 455 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 456 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 457 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 458 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 459 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 460 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 461 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 462 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 463 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 464 | 465 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 466 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 467 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 468 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 469 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 470 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 471 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 472 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 473 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 474 | 475 | c. The disclaimer of warranties and limitation of liability provided 476 | above shall be interpreted in a manner that, to the extent 477 | possible, most closely approximates an absolute disclaimer and 478 | waiver of all liability. 479 | 480 | Section 6 -- Term and Termination. 481 | 482 | a. This Public License applies for the term of the Copyright and 483 | Similar Rights licensed here. However, if You fail to comply with 484 | this Public License, then Your rights under this Public License 485 | terminate automatically. 486 | 487 | b. Where Your right to use the Licensed Material has terminated under 488 | Section 6(a), it reinstates: 489 | 490 | 1. automatically as of the date the violation is cured, provided 491 | it is cured within 30 days of Your discovery of the 492 | violation; or 493 | 494 | 2. upon express reinstatement by the Licensor. 495 | 496 | For the avoidance of doubt, this Section 6(b) does not affect any 497 | right the Licensor may have to seek remedies for Your violations 498 | of this Public License. 499 | 500 | c. For the avoidance of doubt, the Licensor may also offer the 501 | Licensed Material under separate terms or conditions or stop 502 | distributing the Licensed Material at any time; however, doing so 503 | will not terminate this Public License. 504 | 505 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 506 | License. 507 | 508 | Section 7 -- Other Terms and Conditions. 509 | 510 | a. The Licensor shall not be bound by any additional or different 511 | terms or conditions communicated by You unless expressly agreed. 512 | 513 | b. Any arrangements, understandings, or agreements regarding the 514 | Licensed Material not stated herein are separate from and 515 | independent of the terms and conditions of this Public License. 516 | 517 | Section 8 -- Interpretation. 518 | 519 | a. For the avoidance of doubt, this Public License does not, and 520 | shall not be interpreted to, reduce, limit, restrict, or impose 521 | conditions on any use of the Licensed Material that could lawfully 522 | be made without permission under this Public License. 523 | 524 | b. To the extent possible, if any provision of this Public License is 525 | deemed unenforceable, it shall be automatically reformed to the 526 | minimum extent necessary to make it enforceable. If the provision 527 | cannot be reformed, it shall be severed from this Public License 528 | without affecting the enforceability of the remaining terms and 529 | conditions. 530 | 531 | c. No term or condition of this Public License will be waived and no 532 | failure to comply consented to unless expressly agreed to by the 533 | Licensor. 534 | 535 | d. Nothing in this Public License constitutes or may be interpreted 536 | as a limitation upon, or waiver of, any privileges and immunities 537 | that apply to the Licensor or You, including from the legal 538 | processes of any jurisdiction or authority. 539 | 540 | ======================================================================= 541 | 542 | Creative Commons is not a party to its public 543 | licenses. Notwithstanding, Creative Commons may elect to apply one of 544 | its public licenses to material it publishes and in those instances 545 | will be considered the “Licensor.” The text of the Creative Commons 546 | public licenses is dedicated to the public domain under the CC0 Public 547 | Domain Dedication. Except for the limited purpose of indicating that 548 | material is shared under a Creative Commons public license or as 549 | otherwise permitted by the Creative Commons policies published at 550 | creativecommons.org/policies, Creative Commons does not authorize the 551 | use of the trademark "Creative Commons" or any other trademark or logo 552 | of Creative Commons without its prior written consent including, 553 | without limitation, in connection with any unauthorized modifications 554 | to any of its public licenses or any other arrangements, 555 | understandings, or agreements concerning use of licensed material. For 556 | the avoidance of doubt, this paragraph does not form part of the 557 | public licenses. 558 | 559 | Creative Commons may be contacted at creativecommons.org. 560 | --------------------------------------------------------------------------------