├── README.md ├── getting-started ├── README.md ├── truffle │ ├── test │ │ ├── .gitkeep │ │ └── greeter-test.js │ ├── .gitignore │ ├── migrations │ │ ├── 2_deploy_contracts.js │ │ └── 1_initial_migration.js │ ├── .env.example │ ├── package.json │ ├── contracts │ │ ├── Migrations.sol │ │ └── Greeter.sol │ └── truffle-config.js ├── hardhat │ ├── .gitignore │ ├── .env.example │ ├── package.json │ ├── contracts │ │ └── Greeter.sol │ ├── test │ │ └── sample-test.js │ ├── scripts │ │ └── deploy-script.js │ └── hardhat.config.js └── assets │ ├── remix-query.png │ ├── remix-connect.png │ ├── remix-deploy.png │ ├── remix-run-icon.png │ ├── remix-files-icon.png │ └── remix-upload-icon.png ├── sdk-view-tx ├── .env.example ├── package.json ├── README.md └── view-tx.js ├── standard-bridge-custom-token ├── .env.example ├── contracts │ ├── L2CustomERC20.sol │ └── PatexUselessToken.sol ├── package.json ├── hardhat.config.js └── README.md ├── standard-bridge-standard-token ├── .env.example ├── package.json ├── hardhat.config.js ├── scripts │ ├── bridge │ │ ├── 00-standard-token-deploy.js │ │ └── 01-standard-token-bridge.js │ └── deploy │ │ └── 00-deploy-patex-useless-token.js ├── README.md └── contracts │ └── PatexUselessToken.sol ├── sdk-estimate-gas ├── .env.example ├── package.json ├── README.md ├── gas.js └── Greeter.json ├── .gitignore ├── cross-dom-bridge-erc20 ├── .env.example ├── package.json ├── README.md └── index.js └── cross-dom-bridge-eth ├── package.json ├── .env.example ├── README.md ├── withdraw_feevault.js ├── index.js └── withdrawd.js /README.md: -------------------------------------------------------------------------------- 1 | # patex-tutorial -------------------------------------------------------------------------------- /getting-started/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /getting-started/truffle/test/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /getting-started/truffle/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | #Truffle files 4 | build 5 | -------------------------------------------------------------------------------- /sdk-view-tx/.env.example: -------------------------------------------------------------------------------- 1 | L1URL=<<< L1 URL goes here >>> 2 | L2URL=<<< L2 URL goes here >>> 3 | -------------------------------------------------------------------------------- /standard-bridge-custom-token/.env.example: -------------------------------------------------------------------------------- 1 | MNEMONIC= 2 | L1_ALCHEMY_KEY= 3 | L1_TOKEN_ADDRESS= 4 | -------------------------------------------------------------------------------- /getting-started/hardhat/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | #Hardhat files 4 | cache 5 | artifacts 6 | -------------------------------------------------------------------------------- /getting-started/assets/remix-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patex-ecosystem/patex-tutorial/HEAD/getting-started/assets/remix-query.png -------------------------------------------------------------------------------- /standard-bridge-standard-token/.env.example: -------------------------------------------------------------------------------- 1 | MNEMONIC= 2 | L1_RPC_URL= 3 | 4 | L1_TOKEN_ADDRESS=0x04459A4D7d1d7BFb48EBc635e30169D50D56EEAC 5 | -------------------------------------------------------------------------------- /getting-started/assets/remix-connect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patex-ecosystem/patex-tutorial/HEAD/getting-started/assets/remix-connect.png -------------------------------------------------------------------------------- /getting-started/assets/remix-deploy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patex-ecosystem/patex-tutorial/HEAD/getting-started/assets/remix-deploy.png -------------------------------------------------------------------------------- /getting-started/assets/remix-run-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patex-ecosystem/patex-tutorial/HEAD/getting-started/assets/remix-run-icon.png -------------------------------------------------------------------------------- /getting-started/assets/remix-files-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patex-ecosystem/patex-tutorial/HEAD/getting-started/assets/remix-files-icon.png -------------------------------------------------------------------------------- /getting-started/assets/remix-upload-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patex-ecosystem/patex-tutorial/HEAD/getting-started/assets/remix-upload-icon.png -------------------------------------------------------------------------------- /getting-started/truffle/migrations/2_deploy_contracts.js: -------------------------------------------------------------------------------- 1 | var Greeter = artifacts.require("Greeter") 2 | 3 | module.exports = deployer => { 4 | deployer.deploy(Greeter, "Hello, World") 5 | } 6 | -------------------------------------------------------------------------------- /getting-started/truffle/migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | const Migrations = artifacts.require("Migrations"); 2 | 3 | module.exports = function (deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /getting-started/hardhat/.env.example: -------------------------------------------------------------------------------- 1 | # Put the mnemonic for an account on Patex here 2 | MNEMONIC=test test test test test test test test test test test junk 3 | 4 | # URL to access Patex Sepolia 5 | PATEX_SEPOLIA_URL= 6 | -------------------------------------------------------------------------------- /getting-started/truffle/.env.example: -------------------------------------------------------------------------------- 1 | # Put the mnemonic for an account on Patex here 2 | MNEMONIC=test test test test test test test test test test test junk 3 | 4 | # URL to access Patex Sepolia 5 | PATEX_SEPOLIA_URL= 6 | -------------------------------------------------------------------------------- /sdk-estimate-gas/.env.example: -------------------------------------------------------------------------------- 1 | # Put the mnemonic for an account on Patex here 2 | MNEMONIC=test test test test test test test test test test test junk 3 | # URL to access Patex Sepolia 4 | PATEX_SEPOLIA_URL=https://test-rpc.patex.io 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Project specific 2 | deployments 3 | optimism 4 | 5 | # environment variables 6 | .env 7 | .env.local 8 | *.delme 9 | 10 | # Packages 11 | node_modules/ 12 | 13 | # Hardhat build outputs 14 | artifacts/ 15 | cache/ 16 | build -------------------------------------------------------------------------------- /cross-dom-bridge-erc20/.env.example: -------------------------------------------------------------------------------- 1 | # Put the mnemonic for an account on Patex here 2 | MNEMONIC="test test test test test test test test test test test junk" 3 | L1_SEPOLIA_URL="https://eth-sepolia.g.alchemy.com/v2/YOUR_API_KEY" 4 | L2_PATEX_SEPOLIA_URL="https://test-rpc.patex.io" -------------------------------------------------------------------------------- /getting-started/truffle/test/greeter-test.js: -------------------------------------------------------------------------------- 1 | const Greeter = artifacts.require("Greeter") 2 | 3 | contract('Greeter', accounts => { 4 | it("Should work", async () => { 5 | greeter = await Greeter.at("0x317ccBB804c1f104b0fA1495B625c87F66091745") 6 | console.log(await greeter.greet()) 7 | }); // it ... ); 8 | }); // contact ... 9 | -------------------------------------------------------------------------------- /sdk-view-tx/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "view-tx", 3 | "version": "1.0.0", 4 | "main": "view-tx.js", 5 | "license": "MIT", 6 | "dependencies": { 7 | "@eth-patex/sdk": "^1.0.1", 8 | "dotenv": "^16.0.0", 9 | "ethers": "^5.6.1" 10 | }, 11 | "scripts": { 12 | "script": "node view-tx.js" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /cross-dom-bridge-eth/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "l1-to-l2-comm", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "license": "MIT", 6 | "dependencies": { 7 | "@eth-patex/sdk": "^1.0.1", 8 | "dotenv": "^16.1.4", 9 | "ethers": "^5.7.2" 10 | }, 11 | "scripts": { 12 | "script": "node index.js" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /cross-dom-bridge-erc20/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cross-dom-bridge-erc20", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "license": "MIT", 6 | "dependencies": { 7 | "@eth-patex/sdk": "^1.0.1", 8 | "dotenv": "^16.0.0", 9 | "ethers": "^5.7.2" 10 | }, 11 | "scripts": { 12 | "script": "node index.js" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /sdk-estimate-gas/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sdk-gas-estimate", 3 | "version": "1.0.0", 4 | "main": "gas.js", 5 | "license": "MIT", 6 | "dependencies": { 7 | "@eth-patex/sdk": "^1.0.1", 8 | "dotenv": "^16.0.1", 9 | "ethers": "^5.7.2", 10 | "yargs": "^17.7.2" 11 | }, 12 | "scripts": { 13 | "estimate": "node gas.js" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /getting-started/truffle/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "truffle", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "license": "MIT", 6 | "dependencies": { 7 | "@truffle/hdwallet-provider": "^2.0.10", 8 | "chai": "^4.3.6", 9 | "dotenv": "^16.0.0", 10 | "truffle": "^5.4.32" 11 | }, 12 | "scripts": { 13 | "compile": "truffle compile", 14 | "test": "truffle test --network local-devnode" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /getting-started/hardhat/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hardhat-project", 3 | "devDependencies": { 4 | "@nomiclabs/hardhat-ethers": "^2.0.4", 5 | "@nomiclabs/hardhat-waffle": "^2.0.2", 6 | "chai": "^4.3.6", 7 | "ethereum-waffle": "^3.4.0", 8 | "ethers": "^5.5.4", 9 | "hardhat": "^2.8.3" 10 | }, 11 | "scripts": { 12 | "compile": "yarn hardhat compile", 13 | "test": "yarn hardhat test" 14 | }, 15 | "dependencies": { 16 | "dotenv": "^16.0.0" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /getting-started/truffle/contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.4.22 <0.9.0; 3 | 4 | contract Migrations { 5 | address public owner = msg.sender; 6 | uint public last_completed_migration; 7 | 8 | modifier restricted() { 9 | require( 10 | msg.sender == owner, 11 | "This function is restricted to the contract's owner" 12 | ); 13 | _; 14 | } 15 | 16 | function setCompleted(uint completed) public restricted { 17 | last_completed_migration = completed; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /standard-bridge-custom-token/contracts/L2CustomERC20.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.5.16 <0.9.0; 3 | 4 | import { L2StandardERC20 } from "@eth-patex/contracts/standards/L2StandardERC20.sol"; 5 | 6 | contract L2CustomERC20 is L2StandardERC20 { 7 | constructor( 8 | address _l2Bridge, 9 | address _l1Token 10 | ) 11 | L2StandardERC20(_l2Bridge, _l1Token, "Custom L2 Token", "L2T") 12 | { 13 | } 14 | 15 | function decimals() public pure override returns (uint8) { 16 | return 8; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /getting-started/hardhat/contracts/Greeter.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier: Unlicense 2 | pragma solidity ^0.8.0; 3 | 4 | contract Greeter { 5 | string greeting; 6 | 7 | event SetGreeting( 8 | address sender, // msg.sender 9 | string greeting 10 | ); 11 | 12 | constructor(string memory _greeting) { 13 | greeting = _greeting; 14 | } 15 | 16 | function greet() public view returns (string memory) { 17 | return greeting; 18 | } 19 | 20 | function setGreeting(string memory _greeting) public { 21 | greeting = _greeting; 22 | emit SetGreeting(msg.sender, _greeting); 23 | } 24 | } -------------------------------------------------------------------------------- /getting-started/truffle/contracts/Greeter.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier: Unlicense 2 | pragma solidity ^0.8.0; 3 | 4 | contract Greeter { 5 | string greeting; 6 | 7 | event SetGreeting( 8 | address sender, // msg.sender 9 | string greeting 10 | ); 11 | 12 | constructor(string memory _greeting) { 13 | greeting = _greeting; 14 | } 15 | 16 | function greet() public view returns (string memory) { 17 | return greeting; 18 | } 19 | 20 | function setGreeting(string memory _greeting) public { 21 | greeting = _greeting; 22 | emit SetGreeting(msg.sender, _greeting); 23 | } 24 | } -------------------------------------------------------------------------------- /standard-bridge-custom-token/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "standard-bridge-tutorial", 3 | "version": "1.0.0", 4 | "license": "MIT", 5 | "scripts": { 6 | "compile": "hardhat compile && hardhat --network patex compile" 7 | }, 8 | "devDependencies": { 9 | "@nomiclabs/hardhat-ethers": "^2.0.2", 10 | "@nomiclabs/hardhat-waffle": "^2.0.1", 11 | "chai": "^4.3.4", 12 | "ethereum-waffle": "^3.4.0", 13 | "ethers": "^5.4.0", 14 | "hardhat": "^2.4.1" 15 | }, 16 | "dependencies": { 17 | "@eth-patex/contracts": "1.0.0", 18 | "@eth-patex/contracts-bedrock": "1.0.0", 19 | "@eth-patex/sdk": "^1.0.1", 20 | "@openzeppelin/contracts": "4.3.2", 21 | "dotenv": "^10.0.0" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /getting-started/hardhat/test/sample-test.js: -------------------------------------------------------------------------------- 1 | const { expect } = require("chai"); 2 | 3 | describe("Greeter", function () { 4 | it("Should return the new greeting once it's changed", async function () { 5 | const Greeter = await ethers.getContractFactory("Greeter"); 6 | const greeter = await Greeter.deploy("Hello, world!"); 7 | await greeter.deployed(); 8 | 9 | console.log(`Addr: ${greeter.address}`) 10 | 11 | expect(await greeter.greet()).to.equal("Hello, world!"); 12 | 13 | const setGreetingTx = await greeter.setGreeting("Hola, mundo!"); 14 | 15 | // wait until the transaction is mined 16 | await setGreetingTx.wait(); 17 | 18 | expect(await greeter.greet()).to.equal("Hola, mundo!"); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /standard-bridge-standard-token/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "standard-bridge-standard-token", 3 | "version": "1.0.0", 4 | "license": "MIT", 5 | "scripts": { 6 | "compile": "hardhat compile && hardhat --network patex-sepolia compile" 7 | }, 8 | "devDependencies": { 9 | "@nomiclabs/hardhat-ethers": "^2.0.2", 10 | "@nomiclabs/hardhat-waffle": "^2.0.1", 11 | "chai": "^4.3.4", 12 | "ethereum-waffle": "^3.4.0", 13 | "ethers": "^5.4.0", 14 | "fs": "^0.0.1-security", 15 | "hardhat": "^2.4.1" 16 | }, 17 | "dependencies": { 18 | "@eth-patex/contracts": "1.0.0", 19 | "@eth-patex/contracts-bedrock": "1.0.0", 20 | "@eth-patex/sdk": "^1.0.1", 21 | "@openzeppelin/contracts": "4.3.2", 22 | "dotenv": "^10.0.0" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /standard-bridge-custom-token/hardhat.config.js: -------------------------------------------------------------------------------- 1 | // Plugins 2 | require('@nomiclabs/hardhat-ethers') 3 | 4 | // Load environment variables from .env 5 | require('dotenv').config(); 6 | 7 | const words = process.env.MNEMONIC.match(/[a-zA-Z]+/g).length 8 | validLength = [12, 15, 18, 24] 9 | if (!validLength.includes(words)) { 10 | console.log(`The mnemonic (${process.env.MNEMONIC}) is the wrong number of words`) 11 | process.exit(-1) 12 | } 13 | 14 | module.exports = { 15 | networks: { 16 | 'patex-sepolia': { 17 | chainId: 471100, 18 | url: `https://test-rpc.patex.io`, 19 | accounts: { mnemonic: process.env.MNEMONIC } 20 | }, 21 | 'sepolia': { 22 | chainId: 11155111, 23 | url: process.env.L1_RPC_URL, 24 | accounts: { mnemonic: process.env.MNEMONIC } 25 | } 26 | }, 27 | solidity: '0.8.13', 28 | } 29 | -------------------------------------------------------------------------------- /standard-bridge-standard-token/hardhat.config.js: -------------------------------------------------------------------------------- 1 | // Plugins 2 | require('@nomiclabs/hardhat-ethers') 3 | 4 | // Load environment variables from .env 5 | require('dotenv').config(); 6 | 7 | 8 | const words = process.env.MNEMONIC.match(/[a-zA-Z]+/g).length 9 | validLength = [12, 15, 18, 24] 10 | if (!validLength.includes(words)) { 11 | console.log(`The mnemonic (${process.env.MNEMONIC}) is the wrong number of words`) 12 | process.exit(-1) 13 | } 14 | 15 | module.exports = { 16 | networks: { 17 | 'patex-sepolia': { 18 | chainId: 471100, 19 | url: `https://test-rpc.patex.io`, 20 | accounts: { mnemonic: process.env.MNEMONIC } 21 | }, 22 | 'sepolia': { 23 | chainId: 11155111, 24 | url: process.env.L1_RPC_URL, 25 | accounts: { mnemonic: process.env.MNEMONIC } 26 | } 27 | }, 28 | solidity: '0.8.13', 29 | } 30 | -------------------------------------------------------------------------------- /standard-bridge-standard-token/scripts/bridge/00-standard-token-deploy.js: -------------------------------------------------------------------------------- 1 | const hre = require("hardhat"); 2 | const fs = require("fs"); 3 | 4 | async function main() { 5 | 6 | const fname = "node_modules/@eth-patex/contracts-bedrock/artifacts/contracts/universal/PatexMintableERC20Factory.sol/PatexMintableERC20Factory.json" 7 | 8 | const ftext = fs.readFileSync(fname).toString().replace(/\n/g, "") 9 | 10 | const patexMintableERC20FactoryData = JSON.parse(ftext) 11 | 12 | const patexMintableERC20Factory = new ethers.Contract( 13 | "0x4200000000000000000000000000000000000012", 14 | patexMintableERC20FactoryData.abi, 15 | await hre.ethers.getSigner() 16 | ) 17 | 18 | const deployTx = await patexMintableERC20Factory.createStandardL2Token( 19 | process.env.L1_TOKEN_ADDRESS, 20 | "PatexUselessToken-1", 21 | "PUT-1" 22 | ) 23 | 24 | await deployTx.wait() 25 | 26 | } 27 | 28 | main() 29 | .then(() => process.exit(0)) 30 | .catch((error) => { 31 | console.error(error); 32 | process.exit(1); 33 | }); 34 | -------------------------------------------------------------------------------- /cross-dom-bridge-eth/.env.example: -------------------------------------------------------------------------------- 1 | # Optional: should uncomment this case in index.js 2 | MNEMONIC= 3 | 4 | ### Common 5 | # Target network: "mainnet" or "sepolia" supported 6 | NETWORK= 7 | # Target fee vault withdraw address 8 | FEE_VAULT_ADDRESS= 9 | # Withdraw threshold in ETH, use dot "." point 10 | WITHDRAW_THRESHOLD= 11 | 12 | ### Sepolia 13 | # Admin key 14 | SEPOLIA_FEE_WITHDRAWAL_PRIVKEY= 15 | # URL's and chain id's 16 | L1_SEPOLIA_URL= 17 | L2_SEPOLIA_URL= 18 | L1_SEPOLIA_CHAIN_ID= 19 | L2_SEPOLIA_CHAIN_ID= 20 | SEPOLIA_BATCHER_ADDRESS= 21 | 22 | ### Mainnet 23 | # Admin key 24 | MAINNET_FEE_WITHDRAWAL_PRIVKEY= 25 | # URL's and chain id's 26 | L1_MAINNET_URL= 27 | L2_MAINNET_URL= 28 | L1_MAINNET_CHAIN_ID= 29 | L2_MAINNET_CHAIN_ID= 30 | MAINNET_BATCHER_ADDRESS= 31 | 32 | ### Timers 33 | # Finalization period: 24 hours for mainnet in miliseconds 24*60*60*1000=86400000 34 | FINALIZATION_PERIOD= 35 | # Proposer period: 5 hours for mainnet in miliseconds 5*60*60*1000=18000000 36 | PT_PROPOSER_PERIOD= 37 | # Balance checking: 10 minutes in milliseconds 10*60*1000=600000 38 | CHECKING_BALANCE_PERIOD= 39 | 40 | 41 | -------------------------------------------------------------------------------- /getting-started/hardhat/scripts/deploy-script.js: -------------------------------------------------------------------------------- 1 | // We require the Hardhat Runtime Environment explicitly here. This is optional 2 | // but useful for running the script in a standalone fashion through `node