├── .dockerignore ├── .github ├── dependabot.yml ├── pull_request_template.md └── workflows │ ├── ci.yml │ └── release.yml ├── .gitignore ├── .gitmodules ├── .golangci.yml ├── LICENSE ├── Makefile ├── README.md ├── SECURITY.md ├── abi ├── abi.go └── abi_test.go ├── bindings ├── funder │ ├── Funder.abi │ ├── Funder.bin │ └── funder.go ├── tester │ ├── ConformanceTester.abi │ ├── ConformanceTester.bin │ ├── LoadTester.abi │ ├── LoadTester.bin │ ├── conformanceTester.go │ ├── helper.go │ ├── loadTester.go │ └── precompiles.go ├── tokens │ ├── ERC20.abi │ ├── ERC20.bin │ ├── ERC20.go │ ├── ERC721.abi │ ├── ERC721.bin │ └── ERC721.go ├── ulxly │ ├── PolygonZkEVMBridge.abi │ ├── PolygonZkEVMBridge.bin │ ├── PolygonZkEVMBridge.go │ ├── PolygonZkEVMBridgeV2.abi │ ├── PolygonZkEVMBridgeV2.bin │ ├── PolygonZkEVMBridgeV2.go │ ├── polygonrollupmanager │ │ ├── PolygonRollupManager.abi │ │ ├── PolygonRollupManager.bin │ │ └── PolygonRollupManager.go │ └── polygonzkevmglobalexitrootl2 │ │ ├── polygonzkevmglobalexitrootl2.abi │ │ ├── polygonzkevmglobalexitrootl2.bin │ │ └── polygonzkevmglobalexitrootl2.go └── uniswapv3 │ ├── IUniswapV3Pool.abi │ ├── IUniswapV3Pool.go │ ├── IUniswapV3Pool.json │ ├── NFTDescriptor.abi │ ├── NFTDescriptor.bin │ ├── NFTDescriptor.go │ ├── NFTDescriptor.json │ ├── NonfungiblePositionManager.abi │ ├── NonfungiblePositionManager.bin │ ├── NonfungiblePositionManager.go │ ├── NonfungiblePositionManager.json │ ├── NonfungibleTokenPositionDescriptor.abi │ ├── NonfungibleTokenPositionDescriptor.bin │ ├── NonfungibleTokenPositionDescriptor.go │ ├── NonfungibleTokenPositionDescriptor.json │ ├── ProxyAdmin.abi │ ├── ProxyAdmin.bin │ ├── ProxyAdmin.go │ ├── ProxyAdmin.json │ ├── QuoterV2.abi │ ├── QuoterV2.bin │ ├── QuoterV2.go │ ├── QuoterV2.json │ ├── README.org │ ├── SwapRouter02.abi │ ├── SwapRouter02.bin │ ├── SwapRouter02.go │ ├── SwapRouter02.json │ ├── TickLens.abi │ ├── TickLens.bin │ ├── TickLens.go │ ├── TickLens.json │ ├── TransparentUpgradeableProxy.abi │ ├── TransparentUpgradeableProxy.bin │ ├── TransparentUpgradeableProxy.go │ ├── TransparentUpgradeableProxy.json │ ├── UniswapInterfaceMulticall.abi │ ├── UniswapInterfaceMulticall.bin │ ├── UniswapInterfaceMulticall.go │ ├── UniswapInterfaceMulticall.json │ ├── UniswapV3Factory.abi │ ├── UniswapV3Factory.bin │ ├── UniswapV3Factory.go │ ├── UniswapV3Factory.json │ ├── UniswapV3Staker.abi │ ├── UniswapV3Staker.bin │ ├── UniswapV3Staker.go │ ├── UniswapV3Staker.json │ ├── V3Migrator.abi │ ├── V3Migrator.bin │ ├── V3Migrator.go │ ├── V3Migrator.json │ ├── WETH9.abi │ ├── WETH9.bin │ ├── WETH9.go │ └── WETH9.json ├── cmd ├── abi │ ├── abi.go │ ├── decode │ │ └── decode.go │ ├── encode │ │ └── encode.go │ └── usage.md ├── cdk │ ├── bridge.go │ ├── bridgeDumpUsage.md │ ├── bridgeInspectUsage.md │ ├── bridgeMonitorUsage.md │ ├── cdk.go │ ├── custom_filter.go │ ├── ger.go │ ├── gerDumpUsage.md │ ├── gerInspectUsage.md │ ├── gerMonitorUsage.md │ ├── interfaces.go │ ├── rollup.go │ ├── rollupDumpUsage.md │ ├── rollupInspectUsage.md │ ├── rollupManagerDumpUsage.md │ ├── rollupManagerInspectUsage.md │ ├── rollupManagerListRollupTypesUsage.md │ ├── rollupManagerListRollupsUsage.md │ ├── rollupManagerMonitorUsage.md │ ├── rollupMonitorUsage.md │ └── rollup_manager.go ├── dbbench │ ├── dbbench.go │ ├── leveldb.go │ ├── pebbledb.go │ └── usage.md ├── dumpblocks │ ├── dumpblocks.go │ └── usage.md ├── ecrecover │ ├── ecrecover.go │ └── usage.md ├── enr │ ├── enr.go │ └── usage.md ├── fixnoncegap │ ├── FixNonceGapUsage.md │ └── fixnoncegap.go ├── flag_loader │ ├── flag_loader.go │ └── flag_loader_test.go ├── foldtrace │ ├── foldtrace.go │ └── usage.md ├── fork │ └── fork.go ├── fund │ ├── cmd.go │ ├── fund.go │ └── usage.md ├── hash │ ├── hash.go │ └── usage.md ├── loadtest │ ├── account.go │ ├── app.go │ ├── blob.go │ ├── loadtest.go │ ├── loadtestUsage.md │ ├── loadtestmode_string.go │ ├── output.go │ ├── recall.go │ ├── uniswapv3.go │ ├── uniswapv3 │ │ ├── deploy.go │ │ ├── pool.go │ │ ├── swap.go │ │ └── swapper.go │ └── uniswapv3Usage.md ├── metricsToDash │ ├── metricsToDash.go │ └── usage.md ├── mnemonic │ └── mnemonic.go ├── monitor │ ├── cmd.go │ ├── monitor.go │ ├── ui │ │ └── ui.go │ └── usage.md ├── nodekey │ ├── nodekey.go │ ├── nodekey_test.go │ ├── secp256k1.go │ └── usage.md ├── p2p │ ├── crawl │ │ ├── crawl.go │ │ └── crawl_util.go │ ├── nodelist │ │ └── nodelist.go │ ├── p2p.go │ ├── ping │ │ └── ping.go │ ├── query │ │ └── query.go │ ├── sensor │ │ └── sensor.go │ └── usage.md ├── parseethwallet │ ├── parseethwallet.go │ └── usage.md ├── publish │ ├── input.go │ ├── output.go │ ├── publish.go │ ├── publish.md │ ├── script │ │ └── filegen.go │ └── worker_pool.go ├── retest │ ├── retest.go │ └── usage.md ├── root.go ├── rpcfuzz │ ├── README.org │ ├── argfuzz │ │ └── argfuzz.go │ ├── cmd.go │ ├── rpcfuzz.go │ ├── testreporter │ │ └── testreporter.go │ └── usage.md ├── signer │ ├── createCmdUsage.md │ ├── importCmdUsage.md │ ├── listCmdUsage.md │ ├── signCmdUsage.md │ ├── signer.go │ └── usage.md ├── ulxly │ ├── BridgeAssetUsage.md │ ├── BridgeMessageUsage.md │ ├── BridgeWETHMessageUsage.md │ ├── ClaimAssetUsage.md │ ├── ClaimMessageUsage.md │ ├── balanceTreeUsage.md │ ├── balanceandnullifiertreehelper.go │ ├── balanceandnullifiertreehelper_test.go │ ├── claimGetUsage.md │ ├── depositGetUsage.md │ ├── nullifierAndBalanceTreeUsage.md │ ├── nullifierTreeUsage.md │ ├── proofUsage.md │ ├── rollupsProofUsage.md │ ├── testvectors │ │ ├── balancetree.json │ │ ├── nullifiertree.json │ │ └── vectors.go │ ├── tree-diagram.png │ ├── tree-diagram.tex │ ├── ulxly.go │ └── verifyBatchesGetUsage.md ├── version │ └── version.go ├── wallet │ ├── usage.md │ └── wallet.go └── wrapcontract │ ├── usage.md │ └── wrapcontract.go ├── contracts ├── .gitignore ├── Makefile ├── README.md ├── foundry.toml └── src │ ├── asm │ ├── README.md │ ├── blockhash-gas-loop.easm │ ├── delegate-call-loop.easm │ ├── deploy-call-loop.easm │ ├── deploy-header.easm │ ├── deploy.easm │ ├── fib-nostore.easm │ ├── fib.easm │ ├── noop-loop.easm │ └── sstore-loop.easm │ ├── funder │ └── Funder.sol │ ├── tester │ ├── ConformanceTester.sol │ └── LoadTester.sol │ └── tokens │ ├── ERC20.sol │ └── ERC721.sol ├── custom_marshaller └── custom_marshaller.go ├── dashboard └── dashboard.go ├── doc ├── assets │ └── monitor.gif ├── grafana_panoptichain_dashboard.png ├── load-testing-guide.md ├── polycli.md ├── polycli_abi.md ├── polycli_abi_decode.md ├── polycli_abi_encode.md ├── polycli_cdk.md ├── polycli_cdk_bridge.md ├── polycli_cdk_bridge_dump.md ├── polycli_cdk_bridge_inspect.md ├── polycli_cdk_bridge_monitor.md ├── polycli_cdk_ger.md ├── polycli_cdk_ger_dump.md ├── polycli_cdk_ger_inspect.md ├── polycli_cdk_ger_monitor.md ├── polycli_cdk_rollup-manager.md ├── polycli_cdk_rollup-manager_dump.md ├── polycli_cdk_rollup-manager_inspect.md ├── polycli_cdk_rollup-manager_list-rollup-types.md ├── polycli_cdk_rollup-manager_list-rollups.md ├── polycli_cdk_rollup-manager_monitor.md ├── polycli_cdk_rollup.md ├── polycli_cdk_rollup_dump.md ├── polycli_cdk_rollup_inspect.md ├── polycli_cdk_rollup_monitor.md ├── polycli_dbbench.md ├── polycli_dumpblocks.md ├── polycli_ecrecover.md ├── polycli_enr.md ├── polycli_fix-nonce-gap.md ├── polycli_fold-trace.md ├── polycli_fork.md ├── polycli_fund.md ├── polycli_hash.md ├── polycli_loadtest.md ├── polycli_loadtest_uniswapv3.md ├── polycli_metrics-to-dash.md ├── polycli_mnemonic.md ├── polycli_monitor.md ├── polycli_monitor.png ├── polycli_nodekey.md ├── polycli_p2p.md ├── polycli_p2p_crawl.md ├── polycli_p2p_nodelist.md ├── polycli_p2p_ping.md ├── polycli_p2p_query.md ├── polycli_p2p_sensor.md ├── polycli_parseethwallet.md ├── polycli_publish.md ├── polycli_retest.md ├── polycli_rpcfuzz.md ├── polycli_signer.md ├── polycli_signer_create.md ├── polycli_signer_import.md ├── polycli_signer_list.md ├── polycli_signer_sign.md ├── polycli_ulxly.md ├── polycli_ulxly_bridge.md ├── polycli_ulxly_bridge_asset.md ├── polycli_ulxly_bridge_message.md ├── polycli_ulxly_bridge_weth.md ├── polycli_ulxly_claim-everything.md ├── polycli_ulxly_claim.md ├── polycli_ulxly_claim_asset.md ├── polycli_ulxly_claim_message.md ├── polycli_ulxly_compute-balance-nullifier-tree.md ├── polycli_ulxly_compute-balance-tree.md ├── polycli_ulxly_compute-nullifier-tree.md ├── polycli_ulxly_empty-proof.md ├── polycli_ulxly_get-claims.md ├── polycli_ulxly_get-deposits.md ├── polycli_ulxly_get-verify-batches.md ├── polycli_ulxly_proof.md ├── polycli_ulxly_rollups-proof.md ├── polycli_ulxly_zero-proof.md ├── polycli_version.md ├── polycli_wallet.md └── polycli_wrap-contract.md ├── docker ├── Dockerfile.gen-doc ├── Dockerfile.gen-go-bindings ├── Dockerfile.gen-json-rpc-types ├── Dockerfile.gen-load-test-modes └── Dockerfile.gen-proto ├── docutil ├── doc.go ├── main.go └── readme.go ├── gethkeystore └── gethkeystore.go ├── go.mod ├── go.sum ├── hdwallet ├── hdwallet.go └── hdwallet_test.go ├── main.go ├── metrics └── metrics.go ├── p2p ├── database │ ├── database.go │ └── datastore.go ├── log.go ├── nodeset.go ├── p2p.go ├── protocol.go ├── rlpx.go └── types.go ├── packaging ├── deb │ └── polycli │ │ └── DEBIAN │ │ └── README.md └── templates │ └── package_scripts │ └── control ├── proto ├── block.proto ├── gen │ └── pb │ │ ├── block.pb.go │ │ └── transaction.pb.go └── transaction.proto ├── rpctypes ├── jsonschemas │ ├── README.org │ ├── debug_getBadBlocks.json │ ├── debug_getRawBlock.json │ ├── debug_getRawHeader.json │ ├── debug_getRawReceipts.json │ ├── debug_getRawTransaction.json │ ├── engine_exchangeCapabilities.json │ ├── engine_exchangeTransitionConfigurationV1.json │ ├── engine_forkchoiceUpdatedV1.json │ ├── engine_forkchoiceUpdatedV2.json │ ├── engine_forkchoiceUpdatedV3.json │ ├── engine_getPayloadBodiesByHashV1.json │ ├── engine_getPayloadBodiesByRangeV1.json │ ├── engine_getPayloadV1.json │ ├── engine_getPayloadV2.json │ ├── engine_getPayloadV3.json │ ├── engine_getPayloadV4.json │ ├── engine_newPayloadV1.json │ ├── engine_newPayloadV2.json │ ├── engine_newPayloadV3.json │ ├── engine_newPayloadV4.json │ ├── eth_accounts.json │ ├── eth_blobBaseFee.json │ ├── eth_blockNumber.json │ ├── eth_call.json │ ├── eth_chainId.json │ ├── eth_coinbase.json │ ├── eth_createAccessList.json │ ├── eth_estimateGas.json │ ├── eth_feeHistory.json │ ├── eth_gasPrice.json │ ├── eth_getBalance.json │ ├── eth_getBlockByHash.json │ ├── eth_getBlockByNumber.json │ ├── eth_getBlockReceipts.json │ ├── eth_getBlockTransactionCountByHash.json │ ├── eth_getBlockTransactionCountByNumber.json │ ├── eth_getCode.json │ ├── eth_getFilterChanges.json │ ├── eth_getFilterLogs.json │ ├── eth_getLogs.json │ ├── eth_getProof.json │ ├── eth_getStorageAt.json │ ├── eth_getTransactionByBlockHashAndIndex.json │ ├── eth_getTransactionByBlockNumberAndIndex.json │ ├── eth_getTransactionByHash.json │ ├── eth_getTransactionCount.json │ ├── eth_getTransactionReceipt.json │ ├── eth_getUncleCountByBlockHash.json │ ├── eth_getUncleCountByBlockNumber.json │ ├── eth_maxPriorityFeePerGas.json │ ├── eth_newBlockFilter.json │ ├── eth_newFilter.json │ ├── eth_newPendingTransactionFilter.json │ ├── eth_sendRawTransaction.json │ ├── eth_sendTransaction.json │ ├── eth_sign.json │ ├── eth_signTransaction.json │ ├── eth_syncing.json │ ├── eth_uninstallFilter.json │ ├── openrpc.json │ ├── rpcschemadebugblock.json │ ├── rpcschemadebugtrace.json │ ├── rpcschemahexarray.json │ └── rpcschemasigntxresponse.json ├── rpctypes.go └── schemas.go ├── scripts ├── clients.mk ├── lint.mk └── rpctypes.sh ├── sonar-project.properties └── util ├── convert.go ├── log.go ├── send.go ├── url.go └── util.go /.dockerignore: -------------------------------------------------------------------------------- 1 | tmp/ -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | updates: 4 | - package-ecosystem: gomod 5 | directory: "/" 6 | schedule: 7 | interval: weekly 8 | 9 | - package-ecosystem: github-actions 10 | directory: "/" 11 | schedule: 12 | interval: weekly 13 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | 6 | 7 | ## Jira / Linear Tickets 8 | 9 | - [DVT-000]() 10 | 11 | # Testing 12 | 13 | 16 | 17 | - [ ] Test A 18 | - [ ] Test B 19 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | 3 | on: 4 | push: 5 | # run only against tags 6 | tags: 7 | - "*" 8 | 9 | permissions: 10 | contents: write 11 | 12 | env: 13 | GO_VERSION: "1.24.1" 14 | 15 | jobs: 16 | manual-release: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: Checkout sources 20 | uses: actions/checkout@v4 21 | 22 | - name: Install go 23 | uses: actions/setup-go@v5 24 | with: 25 | go-version: ${{ env.GO_VERSION }} 26 | 27 | - name: Install packages 28 | run: sudo apt-get update && sudo apt-get install --yes gcc-aarch64-linux-gnu 29 | 30 | - name: Perform cross builds 31 | run: make cross 32 | 33 | - name: Compress binaries 34 | run: | 35 | cd out 36 | tar czf polycli_${GITHUB_REF#refs/tags/}_linux_arm64.tar.gz polycli_${GITHUB_REF#refs/tags/}_linux_arm64/ 37 | tar czf polycli_${GITHUB_REF#refs/tags/}_linux_amd64.tar.gz polycli_${GITHUB_REF#refs/tags/}_linux_amd64/ 38 | 39 | - name: Get git tag 40 | run: echo "tag=$(git describe --tags --exact-match HEAD)" >> $GITHUB_ENV 41 | 42 | - name: Publish binaries 43 | uses: svenstaro/upload-release-action@04733e069f2d7f7f0b4aebc4fbdbce8613b03ccd # 2.9.0 44 | with: 45 | repo_token: ${{ secrets.GITHUB_TOKEN }} 46 | tag: ${{ env.tag }} 47 | release_name: ${{ env.tag }} 48 | file_glob: true 49 | file: out/*.tar.gz 50 | overwrite: true 51 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | out/ 2 | tmp/ 3 | .DS_Store 4 | coverage.out 5 | 6 | .vscode 7 | .idea 8 | *.swp 9 | *.swo 10 | 11 | wallets.json 12 | 13 | *.key 14 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "contracts/lib/forge-std"] 2 | path = contracts/lib/forge-std 3 | url = https://github.com/foundry-rs/forge-std 4 | [submodule "contracts/lib/openzeppelin-contracts"] 5 | path = contracts/lib/openzeppelin-contracts 6 | url = https://github.com/OpenZeppelin/openzeppelin-contracts 7 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | linters: 2 | enable: 3 | - gofmt 4 | - govet 5 | - staticcheck 6 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Polygon Technology Security Information 2 | 3 | ## Link to vulnerability disclosure details (Bug Bounty). 4 | 5 | - Websites and Applications: [https://hackerone.com/polygon-technology](https://hackerone.com/polygon-technology) 6 | - Smart Contracts: [https://immunefi.com/bounty/polygon](https://immunefi.com/bounty/polygon) 7 | 8 | ## Languages that our team speaks and understands. 9 | 10 | Preferred-Languages: en 11 | 12 | ## Security-related job openings at Polygon. 13 | 14 | [https://polygon.technology/careers](https://polygon.technology/careers) 15 | 16 | ## Polygon security contact details. 17 | 18 | [security@polygon.technology](mailto:security@polygon.technology) 19 | 20 | ## The URL for accessing the security.txt file. 21 | 22 | Canonical: [https://polygon.technology/security.txt](https://polygon.technology/security.txt) 23 | -------------------------------------------------------------------------------- /bindings/funder/Funder.abi: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "constructor", 4 | "inputs": [ 5 | { 6 | "name": "_amount", 7 | "type": "uint256", 8 | "internalType": "uint256" 9 | } 10 | ], 11 | "stateMutability": "nonpayable" 12 | }, 13 | { 14 | "type": "receive", 15 | "stateMutability": "payable" 16 | }, 17 | { 18 | "type": "function", 19 | "name": "amount", 20 | "inputs": [], 21 | "outputs": [ 22 | { 23 | "name": "", 24 | "type": "uint256", 25 | "internalType": "uint256" 26 | } 27 | ], 28 | "stateMutability": "view" 29 | }, 30 | { 31 | "type": "function", 32 | "name": "bulkFund", 33 | "inputs": [ 34 | { 35 | "name": "_addresses", 36 | "type": "address[]", 37 | "internalType": "address[]" 38 | } 39 | ], 40 | "outputs": [], 41 | "stateMutability": "nonpayable" 42 | }, 43 | { 44 | "type": "function", 45 | "name": "fund", 46 | "inputs": [ 47 | { 48 | "name": "_address", 49 | "type": "address", 50 | "internalType": "address" 51 | } 52 | ], 53 | "outputs": [], 54 | "stateMutability": "nonpayable" 55 | } 56 | ] 57 | -------------------------------------------------------------------------------- /bindings/tester/ConformanceTester.abi: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "constructor", 4 | "inputs": [ 5 | { 6 | "name": "_name", 7 | "type": "string", 8 | "internalType": "string" 9 | } 10 | ], 11 | "stateMutability": "nonpayable" 12 | }, 13 | { 14 | "type": "function", 15 | "name": "RevertErrorMessage", 16 | "inputs": [], 17 | "outputs": [ 18 | { 19 | "name": "", 20 | "type": "string", 21 | "internalType": "string" 22 | } 23 | ], 24 | "stateMutability": "view" 25 | }, 26 | { 27 | "type": "function", 28 | "name": "balances", 29 | "inputs": [ 30 | { 31 | "name": "", 32 | "type": "address", 33 | "internalType": "address" 34 | } 35 | ], 36 | "outputs": [ 37 | { 38 | "name": "", 39 | "type": "uint256", 40 | "internalType": "uint256" 41 | } 42 | ], 43 | "stateMutability": "view" 44 | }, 45 | { 46 | "type": "function", 47 | "name": "deposit", 48 | "inputs": [ 49 | { 50 | "name": "amount", 51 | "type": "uint256", 52 | "internalType": "uint256" 53 | } 54 | ], 55 | "outputs": [], 56 | "stateMutability": "nonpayable" 57 | }, 58 | { 59 | "type": "function", 60 | "name": "name", 61 | "inputs": [], 62 | "outputs": [ 63 | { 64 | "name": "", 65 | "type": "string", 66 | "internalType": "string" 67 | } 68 | ], 69 | "stateMutability": "view" 70 | }, 71 | { 72 | "type": "function", 73 | "name": "testRevert", 74 | "inputs": [], 75 | "outputs": [], 76 | "stateMutability": "pure" 77 | } 78 | ] 79 | -------------------------------------------------------------------------------- /bindings/ulxly/polygonzkevmglobalexitrootl2/polygonzkevmglobalexitrootl2.bin: -------------------------------------------------------------------------------- 1 | 60a060405234801561000f575f5ffd5b506040516103fe3803806103fe833981810160405281019061003191906100c9565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100f4565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100988261006f565b9050919050565b6100a88161008e565b81146100b2575f5ffd5b50565b5f815190506100c38161009f565b92915050565b5f602082840312156100de576100dd61006b565b5b5f6100eb848285016100b5565b91505092915050565b6080516102ec6101125f395f818160f2015261018101526102ec5ff3fe608060405234801561000f575f5ffd5b506004361061004a575f3560e01c806301fd90441461004e578063257b36321461006c57806333d6247d1461009c578063a3c573eb146100b8575b5f5ffd5b6100566100d6565b60405161006391906101bb565b60405180910390f35b61008660048036038101906100819190610202565b6100dc565b6040516100939190610245565b60405180910390f35b6100b660048036038101906100b19190610202565b6100f0565b005b6100c061017f565b6040516100cd919061029d565b60405180910390f35b60015481565b5f602052805f5260405f205f915090505481565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610175576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060018190555050565b7f000000000000000000000000000000000000000000000000000000000000000081565b5f819050919050565b6101b5816101a3565b82525050565b5f6020820190506101ce5f8301846101ac565b92915050565b5f5ffd5b6101e1816101a3565b81146101eb575f5ffd5b50565b5f813590506101fc816101d8565b92915050565b5f60208284031215610217576102166101d4565b5b5f610224848285016101ee565b91505092915050565b5f819050919050565b61023f8161022d565b82525050565b5f6020820190506102585f830184610236565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6102878261025e565b9050919050565b6102978161027d565b82525050565b5f6020820190506102b05f83018461028e565b9291505056fea2646970667358221220c393973a9ae757dd7bd5220cac1b2d60f5f06c1013be10c2e6464de440e474f864736f6c634300081c0033 -------------------------------------------------------------------------------- /bindings/uniswapv3/TickLens.abi: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "address", 6 | "name": "pool", 7 | "type": "address" 8 | }, 9 | { 10 | "internalType": "int16", 11 | "name": "tickBitmapIndex", 12 | "type": "int16" 13 | } 14 | ], 15 | "name": "getPopulatedTicksInWord", 16 | "outputs": [ 17 | { 18 | "components": [ 19 | { 20 | "internalType": "int24", 21 | "name": "tick", 22 | "type": "int24" 23 | }, 24 | { 25 | "internalType": "int128", 26 | "name": "liquidityNet", 27 | "type": "int128" 28 | }, 29 | { 30 | "internalType": "uint128", 31 | "name": "liquidityGross", 32 | "type": "uint128" 33 | } 34 | ], 35 | "internalType": "struct ITickLens.PopulatedTick[]", 36 | "name": "populatedTicks", 37 | "type": "tuple[]" 38 | } 39 | ], 40 | "stateMutability": "view", 41 | "type": "function" 42 | } 43 | ] 44 | -------------------------------------------------------------------------------- /bindings/uniswapv3/UniswapInterfaceMulticall.abi: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "name": "getCurrentBlockTimestamp", 5 | "outputs": [ 6 | { 7 | "internalType": "uint256", 8 | "name": "timestamp", 9 | "type": "uint256" 10 | } 11 | ], 12 | "stateMutability": "view", 13 | "type": "function" 14 | }, 15 | { 16 | "inputs": [ 17 | { 18 | "internalType": "address", 19 | "name": "addr", 20 | "type": "address" 21 | } 22 | ], 23 | "name": "getEthBalance", 24 | "outputs": [ 25 | { 26 | "internalType": "uint256", 27 | "name": "balance", 28 | "type": "uint256" 29 | } 30 | ], 31 | "stateMutability": "view", 32 | "type": "function" 33 | }, 34 | { 35 | "inputs": [ 36 | { 37 | "components": [ 38 | { 39 | "internalType": "address", 40 | "name": "target", 41 | "type": "address" 42 | }, 43 | { 44 | "internalType": "uint256", 45 | "name": "gasLimit", 46 | "type": "uint256" 47 | }, 48 | { 49 | "internalType": "bytes", 50 | "name": "callData", 51 | "type": "bytes" 52 | } 53 | ], 54 | "internalType": "struct UniswapInterfaceMulticall.Call[]", 55 | "name": "calls", 56 | "type": "tuple[]" 57 | } 58 | ], 59 | "name": "multicall", 60 | "outputs": [ 61 | { 62 | "internalType": "uint256", 63 | "name": "blockNumber", 64 | "type": "uint256" 65 | }, 66 | { 67 | "components": [ 68 | { 69 | "internalType": "bool", 70 | "name": "success", 71 | "type": "bool" 72 | }, 73 | { 74 | "internalType": "uint256", 75 | "name": "gasUsed", 76 | "type": "uint256" 77 | }, 78 | { 79 | "internalType": "bytes", 80 | "name": "returnData", 81 | "type": "bytes" 82 | } 83 | ], 84 | "internalType": "struct UniswapInterfaceMulticall.Result[]", 85 | "name": "returnData", 86 | "type": "tuple[]" 87 | } 88 | ], 89 | "stateMutability": "nonpayable", 90 | "type": "function" 91 | } 92 | ] 93 | -------------------------------------------------------------------------------- /cmd/abi/abi.go: -------------------------------------------------------------------------------- 1 | package abi 2 | 3 | import ( 4 | "github.com/spf13/cobra" 5 | 6 | _ "embed" 7 | 8 | "github.com/0xPolygon/polygon-cli/cmd/abi/decode" 9 | "github.com/0xPolygon/polygon-cli/cmd/abi/encode" 10 | ) 11 | 12 | var ( 13 | //go:embed usage.md 14 | usage string 15 | ) 16 | 17 | var ABICmd = &cobra.Command{ 18 | Use: "abi", 19 | Short: "Provides encoding and decoding functionalities with contract signatures and ABI.", 20 | Long: usage, 21 | } 22 | 23 | func init() { 24 | ABICmd.AddCommand(decode.ABIDecodeCmd) 25 | ABICmd.AddCommand(encode.ABIEncodeCmd) 26 | } 27 | -------------------------------------------------------------------------------- /cmd/abi/encode/encode.go: -------------------------------------------------------------------------------- 1 | package encode 2 | 3 | import ( 4 | "fmt" 5 | 6 | _ "embed" 7 | 8 | "github.com/spf13/cobra" 9 | 10 | "github.com/0xPolygon/polygon-cli/abi" 11 | ) 12 | 13 | var ( 14 | functionSignature string 15 | functionInputs []string 16 | ) 17 | 18 | var ABIEncodeCmd = &cobra.Command{ 19 | Use: "encode [function signature] [args...]", 20 | Short: "ABI encodes a function signature and the inputs", 21 | Long: "[function-signature] is required and is a fragment in the form (). If the function signature has parameters, then those values would have to be passed as arguments after the function signature.", 22 | Args: cobra.MinimumNArgs(1), 23 | PreRunE: func(cmd *cobra.Command, args []string) error { 24 | functionSignature = args[0] 25 | if len(args) > 1 { 26 | functionInputs = args[1:] 27 | } 28 | 29 | return nil 30 | }, 31 | RunE: func(cmd *cobra.Command, args []string) error { 32 | fullEncoding, err := abi.AbiEncode(functionSignature, functionInputs) 33 | if err != nil { 34 | return err 35 | } 36 | fmt.Println(fullEncoding) 37 | 38 | return nil 39 | }, 40 | } 41 | 42 | func init() {} 43 | -------------------------------------------------------------------------------- /cmd/cdk/bridgeDumpUsage.md: -------------------------------------------------------------------------------- 1 | This command will reach the bridge contract and retrieve detailed information. 2 | 3 | Below is an example of how to use it 4 | 5 | ```bash 6 | polycli cdk bridge dump 7 | --rpc-url https://sepolia.drpc.org 8 | --rollup-manager-address bali 9 | ``` 10 | -------------------------------------------------------------------------------- /cmd/cdk/bridgeInspectUsage.md: -------------------------------------------------------------------------------- 1 | This command will reach the bridge contract and retrieve basic information. 2 | 3 | Below is an example of how to use it 4 | 5 | ```bash 6 | polycli cdk bridge inspect 7 | --rpc-url https://sepolia.drpc.org 8 | --rollup-manager-address bali 9 | ``` 10 | -------------------------------------------------------------------------------- /cmd/cdk/bridgeMonitorUsage.md: -------------------------------------------------------------------------------- 1 | This command will keep watching for bridge events on chain and print them on the fly. 2 | 3 | Below are some example of how to use it 4 | 5 | ```bash 6 | polycli cdk bridge monitor 7 | --rpc-url https://sepolia.drpc.org 8 | --rollup-manager-address bali 9 | ``` 10 | -------------------------------------------------------------------------------- /cmd/cdk/gerDumpUsage.md: -------------------------------------------------------------------------------- 1 | This command will reach the global exit root contract and retrieve detailed information. 2 | 3 | Below is an example of how to use it 4 | 5 | ```bash 6 | polycli cdk ger dump 7 | --rpc-url https://sepolia.drpc.org 8 | --rollup-manager-address bali 9 | ``` 10 | -------------------------------------------------------------------------------- /cmd/cdk/gerInspectUsage.md: -------------------------------------------------------------------------------- 1 | This command will reach the global exit root contract and retrieve basic information. 2 | 3 | Below is an example of how to use it 4 | 5 | ```bash 6 | polycli cdk ger inspect 7 | --rpc-url https://sepolia.drpc.org 8 | --rollup-manager-address bali 9 | ``` 10 | -------------------------------------------------------------------------------- /cmd/cdk/gerMonitorUsage.md: -------------------------------------------------------------------------------- 1 | This command will keep watching for global exit root events on chain and print them on the fly. 2 | 3 | Below are some example of how to use it 4 | 5 | ```bash 6 | polycli cdk ger monitor 7 | --rpc-url https://sepolia.drpc.org 8 | --rollup-manager-address bali 9 | ``` 10 | -------------------------------------------------------------------------------- /cmd/cdk/rollupDumpUsage.md: -------------------------------------------------------------------------------- 1 | This command will reach the rollup manager contract and retrieve detailed information from a specific rollup. 2 | 3 | Below is an example of how to use it 4 | 5 | ```bash 6 | polycli cdk rollup dump 7 | --rpc-url https://sepolia.drpc.org 8 | --rollup-manager-address bali 9 | --rollup-id 1 10 | 11 | polycli cdk rollup dump 12 | --rpc-url https://sepolia.drpc.org 13 | --rollup-manager-address bali 14 | --rollup-chain-id 2440 15 | 16 | polycli cdk rollup dump 17 | --rpc-url https://sepolia.drpc.org 18 | --rollup-manager-address bali 19 | --rollup-address 0x89ba0ed947a88fe43c22ae305c0713ec8a7eb361 20 | ``` 21 | -------------------------------------------------------------------------------- /cmd/cdk/rollupInspectUsage.md: -------------------------------------------------------------------------------- 1 | This command will reach the rollup manager contract and retrieve basic information from a specific rollup. 2 | 3 | Below is an example of how to use it 4 | 5 | ```bash 6 | polycli cdk rollup inspect 7 | --rpc-url https://sepolia.drpc.org 8 | --rollup-manager-address bali 9 | --rollup-id 1 10 | 11 | polycli cdk rollup inspect 12 | --rpc-url https://sepolia.drpc.org 13 | --rollup-manager-address bali 14 | --rollup-chain-id 2440 15 | 16 | polycli cdk rollup inspect 17 | --rpc-url https://sepolia.drpc.org 18 | --rollup-manager-address bali 19 | --rollup-address 0x89ba0ed947a88fe43c22ae305c0713ec8a7eb361 20 | ``` 21 | -------------------------------------------------------------------------------- /cmd/cdk/rollupManagerDumpUsage.md: -------------------------------------------------------------------------------- 1 | This command will reach the rollup manager contract and retrieve detailed information. 2 | 3 | Below is an example of how to use it 4 | 5 | ```bash 6 | polycli cdk rollup-manager dump 7 | --rpc-url https://sepolia.drpc.org 8 | --rollup-manager-address bali 9 | ``` 10 | -------------------------------------------------------------------------------- /cmd/cdk/rollupManagerInspectUsage.md: -------------------------------------------------------------------------------- 1 | This command will reach the rollup manager contract and retrieve basic information. 2 | 3 | Below is an example of how to use it 4 | 5 | ```bash 6 | polycli cdk rollup-manager inspect 7 | --rpc-url https://sepolia.drpc.org 8 | --rollup-manager-address bali 9 | ``` 10 | -------------------------------------------------------------------------------- /cmd/cdk/rollupManagerListRollupTypesUsage.md: -------------------------------------------------------------------------------- 1 | This command will reach the rollup manager contract and retrieve all information about the rollups types registered. 2 | 3 | Below is an example of how to use it 4 | 5 | ```bash 6 | polycli cdk rollup-manager list-rollup-types 7 | --rpc-url https://sepolia.drpc.org 8 | --rollup-manager-address bali 9 | ``` 10 | -------------------------------------------------------------------------------- /cmd/cdk/rollupManagerListRollupsUsage.md: -------------------------------------------------------------------------------- 1 | This command will reach the rollup manager contract and retrieve all information about the rollups registered. 2 | 3 | Below is an example of how to use it 4 | 5 | ```bash 6 | polycli cdk rollup-manager list-rollups 7 | --rpc-url https://sepolia.drpc.org 8 | --rollup-manager-address bali 9 | ``` 10 | -------------------------------------------------------------------------------- /cmd/cdk/rollupManagerMonitorUsage.md: -------------------------------------------------------------------------------- 1 | This command will keep watching for rollup manager events on chain and print them on the fly. 2 | 3 | Below is an example of how to use it 4 | 5 | ```bash 6 | polycli cdk rollup-manager monitor 7 | --rpc-url https://sepolia.drpc.org 8 | --rollup-manager-address bali 9 | ``` 10 | -------------------------------------------------------------------------------- /cmd/cdk/rollupMonitorUsage.md: -------------------------------------------------------------------------------- 1 | This command will keep watching for rollup manager events from a specific rollup on chain and print them on the fly. 2 | 3 | Below are some example of how to use it 4 | 5 | ```bash 6 | polycli cdk rollup monitor 7 | --rpc-url https://sepolia.drpc.org 8 | --rollup-manager-address bali 9 | --rollup-id 1 10 | 11 | polycli cdk rollup monitor 12 | --rpc-url https://sepolia.drpc.org 13 | --rollup-manager-address bali 14 | --rollup-chain-id 2440 15 | 16 | polycli cdk rollup monitor 17 | --rpc-url https://sepolia.drpc.org 18 | --rollup-manager-address bali 19 | --rollup-address 0x89ba0ed947a88fe43c22ae305c0713ec8a7eb361 20 | ``` 21 | -------------------------------------------------------------------------------- /cmd/dbbench/leveldb.go: -------------------------------------------------------------------------------- 1 | package dbbench 2 | 3 | import ( 4 | "github.com/syndtr/goleveldb/leveldb" 5 | "github.com/syndtr/goleveldb/leveldb/filter" 6 | "github.com/syndtr/goleveldb/leveldb/iterator" 7 | "github.com/syndtr/goleveldb/leveldb/opt" 8 | "github.com/syndtr/goleveldb/leveldb/util" 9 | ) 10 | 11 | type ( 12 | LevelDBWrapper struct { 13 | ro *opt.ReadOptions 14 | wo *opt.WriteOptions 15 | handle *leveldb.DB 16 | } 17 | ) 18 | 19 | func NewWrappedLevelDB() (*LevelDBWrapper, error) { 20 | db, err := leveldb.OpenFile(*dbPath, &opt.Options{ 21 | Filter: filter.NewBloomFilter(10), 22 | DisableSeeksCompaction: true, 23 | OpenFilesCacheCapacity: *openFilesCacheCapacity, 24 | BlockCacheCapacity: *cacheSize / 2 * opt.MiB, 25 | WriteBuffer: *cacheSize / 4 * opt.MiB, 26 | // if we've disabled writes, or we're doing a full scan, we should open the database in read only mode 27 | ReadOnly: *readOnly || *fullScan, 28 | }) 29 | if err != nil { 30 | return nil, err 31 | } 32 | 33 | wo := &opt.WriteOptions{ 34 | NoWriteMerge: *noWriteMerge, 35 | Sync: *syncWrites, 36 | } 37 | ro := &opt.ReadOptions{ 38 | DontFillCache: *dontFillCache, 39 | } 40 | if *readStrict { 41 | ro.Strict = opt.StrictAll 42 | } else { 43 | ro.Strict = opt.DefaultStrict 44 | } 45 | if *nilReadOptions { 46 | ro = nil 47 | } 48 | wrapper := new(LevelDBWrapper) 49 | wrapper.handle = db 50 | wrapper.wo = wo 51 | wrapper.ro = ro 52 | return wrapper, nil 53 | } 54 | func (l *LevelDBWrapper) Close() error { 55 | return l.handle.Close() 56 | } 57 | func (l *LevelDBWrapper) Compact() error { 58 | return l.handle.CompactRange(util.Range{Start: nil, Limit: nil}) 59 | } 60 | func (l *LevelDBWrapper) NewIterator() iterator.Iterator { 61 | return l.handle.NewIterator(nil, nil) 62 | } 63 | func (l *LevelDBWrapper) Get(key []byte) ([]byte, error) { 64 | return l.handle.Get(key, l.ro) 65 | } 66 | func (l *LevelDBWrapper) Put(key []byte, value []byte) error { 67 | return l.handle.Put(key, value, l.wo) 68 | } 69 | -------------------------------------------------------------------------------- /cmd/dumpblocks/usage.md: -------------------------------------------------------------------------------- 1 | For various reasons, we might want to dump a large range of blocks for analytics or replay purposes. This is a simple util to export over RPC a range of blocks. 2 | 3 | The following command would download the first 500K blocks and zip them and then look for blocks with transactions that create an account. 4 | 5 | ```bash 6 | $ polycli dumpblocks 0 500000 --rpc-url http://172.26.26.12:8545/ | gzip > foo.gz 7 | $ zcat < foo.gz | jq '. | select(.transactions | length > 0) | select(.transactions[].to == null)' 8 | ``` 9 | 10 | Dumpblocks can also output to protobuf format. 11 | 12 | If you wish to make changes to the protobuf. 13 | 14 | 1. Install the protobuf compiler 15 | 16 | On GNU/Linux: 17 | 18 | ```bash 19 | $ sudo apt install protoc-gen-go 20 | ``` 21 | 22 | On a MAC: 23 | 24 | ```bash 25 | $ brew install protobuf 26 | ``` 27 | 28 | 2. Install the protobuf plugin 29 | 30 | ```bash 31 | $ go install google.golang.org/protobuf/cmd/protoc-gen-go@latest 32 | ``` 33 | 34 | 3. Compile the proto file 35 | 36 | ```bash 37 | $ make generate 38 | ``` 39 | 40 | 4. Depending on what endpoint and chain you're querying, you may be missing some fields in the proto definition. 41 | 42 | ```json 43 | { 44 | "level": "error", 45 | "error": "proto: (line 1:813): unknown field \"nonce\"", 46 | "time": "2023-01-17T13:35:53-05:00", 47 | "message": "failed to unmarshal proto message" 48 | } 49 | ``` 50 | 51 | To solve this, add the unknown fields to the `.proto` files and recompile them (step 3). 52 | -------------------------------------------------------------------------------- /cmd/ecrecover/usage.md: -------------------------------------------------------------------------------- 1 | Recover public key from block 2 | 3 | ```bash 4 | polycli ecrecover -r https://polygon-mumbai-bor.publicnode.com -b 45200775 5 | > Recovering signer from block #45200775 6 | > 0x5082F249cDb2f2c1eE035E4f423c46EA2daB3ab1 7 | 8 | polycli ecrecover -r https://polygon-rpc.com 9 | > Recovering signer from block #52888893 10 | > 0xeEDBa2484aAF940f37cd3CD21a5D7C4A7DAfbfC0 11 | 12 | polycli ecrecover -f block-52888893.json 13 | > Recovering signer from block #52888893 14 | > 0xeEDBa2484aAF940f37cd3CD21a5D7C4A7DAfbfC0 15 | 16 | cat block-52888893.json | go run main.go ecrecover 17 | > Recovering signer from block #52888893 18 | > 0xeEDBa2484aAF940f37cd3CD21a5D7C4A7DAfbfC0 19 | ``` 20 | 21 | JSON Data passed in follows object definition [here](https://www.quicknode.com/docs/ethereum/eth_getBlockByNumber) 22 | -------------------------------------------------------------------------------- /cmd/enr/usage.md: -------------------------------------------------------------------------------- 1 | This function is meant to help handle ENR data. Given an input ENR it will output the parsed enode and other values that are part of the payload. 2 | 3 | The command below will take an ENR and process it: 4 | ```bash 5 | echo 'enr:-IS4QHCYrYZbAKWCBRlAy5zzaDZXJBGkcnh4MHcBFZntXNFrdvJjX04jRzjzCBOonrkTfj499SZuOh8R33Ls8RRcy5wBgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQPKY0yuDUmstAHYpMa2_oxVtw0RW_QAdpzBQA8yWM0xOIN1ZHCCdl8' | \ 6 | polycli enr | jq '.' 7 | ``` 8 | 9 | This is the output: 10 | ```json 11 | { 12 | "enode": "enode://ca634cae0d49acb401d8a4c6b6fe8c55b70d115bf400769cc1400f3258cd31387574077f301b421bc84df7266c44e9e6d569fc56be00812904767bf5ccd1fc7f@127.0.0.1:0?discport=30303", 13 | "enr": "enr:-IS4QHCYrYZbAKWCBRlAy5zzaDZXJBGkcnh4MHcBFZntXNFrdvJjX04jRzjzCBOonrkTfj499SZuOh8R33Ls8RRcy5wBgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQPKY0yuDUmstAHYpMa2_oxVtw0RW_QAdpzBQA8yWM0xOIN1ZHCCdl8", 14 | "id": "a448f24c6d18e575453db13171562b71999873db5b286df957af199ec94617f7", 15 | "ip": "127.0.0.1", 16 | "tcp": "0", 17 | "udp": "30303" 18 | } 19 | ``` 20 | 21 | This command can be used a few different ways 22 | ```bash 23 | enr_data="enr:-IS4QHCYrYZbAKWCBRlAy5zzaDZXJBGkcnh4MHcBFZntXNFrdvJjX04jRzjzCBOonrkTfj499SZuOh8R33Ls8RRcy5wBgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQPKY0yuDUmstAHYpMa2_oxVtw0RW_QAdpzBQA8yWM0xOIN1ZHCCdl8" 24 | 25 | # First form - reading from stdin 26 | echo "$enr_data" | polycli enr 27 | 28 | # Second form - reading from file 29 | tmp_file="$(mktemp)" 30 | echo "$enr_data" > "$tmp_file" 31 | polycli enr --file "$tmp_file" 32 | 33 | # Third form - command line args 34 | polycli enr "$enr_data" 35 | ``` 36 | 37 | All three forms support multiple lines. Each line will be convert into a JSON object and printed. -------------------------------------------------------------------------------- /cmd/fixnoncegap/FixNonceGapUsage.md: -------------------------------------------------------------------------------- 1 | This command will check the account current nonce against the max nonce found in the pool. In case of a nonce gap is found, txs will be sent to fill those gaps. 2 | 3 | To fix a nonce gap, we can use a command like this: 4 | 5 | ```bash 6 | polycli fix-nonce-gap \ 7 | --rpc-url https://sepolia.drpc.org 8 | --private-key 0x32430699cd4f46ab2422f1df4ad6546811be20c9725544e99253a887e971f92b 9 | ``` 10 | 11 | In case the RPC doesn't provide the `txpool_content` endpoint, the flag `--max-nonce` can be set to define the max nonce. The command will generate TXs from the current nonce up to the max nonce set. 12 | 13 | ```bash 14 | polycli fix-nonce-gap \ 15 | --rpc-url https://sepolia.drpc.org 16 | --private-key 0x32430699cd4f46ab2422f1df4ad6546811be20c9725544e99253a887e971f92b 17 | --max-nonce 18 | ``` 19 | 20 | By default, the command will skip TXs found in the pool, for example, let's assume the current nonce is 10, there is a TX with nonce 15 and 20 in the pool. When sending TXs to fill the gaps, the TXs 15 and 20 will be skipped. IN case you want to force these TXs to be replaced, you must provide the flag `--replace`. 21 | 22 | ```bash 23 | polycli fix-nonce-gap \ 24 | --rpc-url https://sepolia.drpc.org 25 | --private-key 0x32430699cd4f46ab2422f1df4ad6546811be20c9725544e99253a887e971f92b 26 | --replace 27 | ``` -------------------------------------------------------------------------------- /cmd/flag_loader/flag_loader.go: -------------------------------------------------------------------------------- 1 | package flag_loader 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | const ( 11 | rpcUrlFlagName, rpcUrlEnvVar = "rpc-url", "ETH_RPC_URL" 12 | privateKeyFlagName, privateKeyEnvVar = "private-key", "PRIVATE_KEY" 13 | ) 14 | 15 | func GetRpcUrlFlagValue(cmd *cobra.Command) *string { 16 | v, _ := getFlagValue(cmd, rpcUrlFlagName, rpcUrlEnvVar, false) 17 | return v 18 | } 19 | 20 | func GetRequiredRpcUrlFlagValue(cmd *cobra.Command) (*string, error) { 21 | return getFlagValue(cmd, rpcUrlFlagName, rpcUrlEnvVar, true) 22 | } 23 | 24 | func GetPrivateKeyFlagValue(cmd *cobra.Command) *string { 25 | v, _ := getFlagValue(cmd, privateKeyFlagName, privateKeyEnvVar, false) 26 | return v 27 | } 28 | 29 | func GetRequiredPrivateKeyFlagValue(cmd *cobra.Command) (*string, error) { 30 | return getFlagValue(cmd, privateKeyFlagName, privateKeyEnvVar, true) 31 | } 32 | 33 | func getFlagValue(cmd *cobra.Command, flagName, envVarName string, required bool) (*string, error) { 34 | flag := cmd.Flag(flagName) 35 | var flagValue string 36 | if flag.Changed { 37 | flagValue = flag.Value.String() 38 | } 39 | flagDefaultValue := flag.DefValue 40 | 41 | envVarValue := os.Getenv(envVarName) 42 | 43 | value := flagDefaultValue 44 | if envVarValue != "" { 45 | value = envVarValue 46 | } 47 | if flag.Changed { 48 | value = flagValue 49 | } 50 | 51 | if required && (!flag.Changed && envVarValue == "") { 52 | return nil, fmt.Errorf("required flag(s) \"%s\" not set", flagName) 53 | } 54 | 55 | return &value, nil 56 | } 57 | -------------------------------------------------------------------------------- /cmd/foldtrace/usage.md: -------------------------------------------------------------------------------- 1 | This command is meant to take a transaction op code trace and convert it into a folded output that can be easily visualized with Flamegraph tools. 2 | 3 | ```bash 4 | # First grab a trace from an RPC that supports the debug namespace 5 | cast rpc --rpc-url http://127.0.0.1:18545 debug_traceTransaction 0x12f63f489213f5bd5b88fbfb12960b8248f61e2062a369ba41d8a3c96bb74d57 > trace.json 6 | 7 | # Read the trace and use the `fold-trace` command and write the output 8 | polycli fold-trace --metric actualgas < trace.json > folded-trace.out 9 | 10 | # Convert the folded trace into a flame graph 11 | flamegraph.pl --title "Gas Profile for 0x7405fc5e254352350bebcadc1392bd06f158aa88e9fb01733389621a29db5f08" --width 1920 --countname folded-trace.out > flame.svg 12 | ``` -------------------------------------------------------------------------------- /cmd/fund/usage.md: -------------------------------------------------------------------------------- 1 | Bulk fund crypto wallets automatically. 2 | 3 | ```bash 4 | # Fund wallets specified by the user. 5 | $ polycli fund --addresses=0x5eD3BE7a1cDafd558F88a673345889dC75837aA2,0x1Ec6efdBd371D6444779eAE7B7e16907e0c8eC27 6 | 3:58PM INF Starting bulk funding wallets 7 | 3:58PM INF Using addresses provided by the user 8 | 3:58PM INF Wallet(s) funded! 💸 9 | 3:58PM INF Total execution time: 1.020693583s 10 | 11 | # Fund 20 random wallets using a pre-deployed contract address. 12 | $ polycli fund --number=20 --contract-address=0xf5a73e7cfcc83b7e8ce2e17eb44f050e8071ee60 13 | 3:58PM INF Starting bulk funding wallets 14 | 3:58PM INF Deriving wallets from the default mnemonic 15 | 3:58PM INF Wallet(s) derived count=20 16 | 3:58PM INF Wallet(s) funded! 💸 17 | 3:58PM INF Total execution time: 396.814917ms 18 | 19 | # Fund 20 random wallets. 20 | $ polycli fund --number 20 --hd-derivation=false 21 | 3:58PM INF Starting bulk funding wallets 22 | 3:58PM INF Generating random wallets 23 | 3:58PM INF Wallet(s) generated count=20 24 | 3:58PM INF Wallets' address(es) and private key(s) saved to file fileName=wallets.json 25 | 3:58PM INF Wallet(s) funded! 💸 26 | 3:58PM INF Total execution time: 1.027506s 27 | ``` 28 | 29 | Extract from `wallets.json`. 30 | 31 | ```json 32 | [ 33 | { 34 | "Address": "0xc1A44B1e37EE1fca4C6Fd5562c730d5b8525e4C6", 35 | "PrivateKey": "c1a8f737fd9f78aee361bfd856f9b2e99f853a5fe5efa2131fb030acdcee762b" 36 | }, 37 | { 38 | "Address": "0x5D8121cf716B70d3e345adB58157752304eED5C3", 39 | "PrivateKey": "fbc57de542cef10fdcdf99e5578ffb5508992e9a8623ea4a39ab957d77e9b849" 40 | }, 41 | ... 42 | ] 43 | ``` 44 | 45 | Check the balances of the wallets. 46 | 47 | ```bash 48 | $ cast balance 0xc1A44B1e37EE1fca4C6Fd5562c730d5b8525e4C6 49 | 50000000000000000 50 | 51 | $ cast balance 0x5D8121cf716B70d3e345adB58157752304eED5C3 52 | 50000000000000000 53 | ... 54 | ``` 55 | -------------------------------------------------------------------------------- /cmd/hash/usage.md: -------------------------------------------------------------------------------- 1 | ```bash 2 | $ echo -n "hello" > hello.txt 3 | $ polycli hash sha1 --file hello.txt 4 | aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d 5 | $ echo -n "hello" | polycli hash sha1 6 | aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d 7 | $ polycli hash sha1 hello 8 | aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d 9 | ``` 10 | -------------------------------------------------------------------------------- /cmd/loadtest/loadtestmode_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -type=loadTestMode"; DO NOT EDIT. 2 | 3 | package loadtest 4 | 5 | import "strconv" 6 | 7 | func _() { 8 | // An "invalid array index" compiler error signifies that the constant values have changed. 9 | // Re-run the stringer command to generate them again. 10 | var x [1]struct{} 11 | _ = x[loadTestModeERC20-0] 12 | _ = x[loadTestModeERC721-1] 13 | _ = x[loadTestModeBlob-2] 14 | _ = x[loadTestModeCall-3] 15 | _ = x[loadTestModeContractCall-4] 16 | _ = x[loadTestModeDeploy-5] 17 | _ = x[loadTestModeFunction-6] 18 | _ = x[loadTestModeInscription-7] 19 | _ = x[loadTestModeIncrement-8] 20 | _ = x[loadTestModeRandomPrecompiledContract-9] 21 | _ = x[loadTestModeSpecificPrecompiledContract-10] 22 | _ = x[loadTestModeRandom-11] 23 | _ = x[loadTestModeRecall-12] 24 | _ = x[loadTestModeRPC-13] 25 | _ = x[loadTestModeStore-14] 26 | _ = x[loadTestModeTransaction-15] 27 | _ = x[loadTestModeUniswapV3-16] 28 | } 29 | 30 | const _loadTestMode_name = "loadTestModeERC20loadTestModeERC721loadTestModeBlobloadTestModeCallloadTestModeContractCallloadTestModeDeployloadTestModeFunctionloadTestModeInscriptionloadTestModeIncrementloadTestModeRandomPrecompiledContractloadTestModeSpecificPrecompiledContractloadTestModeRandomloadTestModeRecallloadTestModeRPCloadTestModeStoreloadTestModeTransactionloadTestModeUniswapV3" 31 | 32 | var _loadTestMode_index = [...]uint16{0, 17, 35, 51, 67, 91, 109, 129, 152, 173, 210, 249, 267, 285, 300, 317, 340, 361} 33 | 34 | func (i loadTestMode) String() string { 35 | if i < 0 || i >= loadTestMode(len(_loadTestMode_index)-1) { 36 | return "loadTestMode(" + strconv.FormatInt(int64(i), 10) + ")" 37 | } 38 | return _loadTestMode_name[_loadTestMode_index[i]:_loadTestMode_index[i+1]] 39 | } 40 | -------------------------------------------------------------------------------- /cmd/loadtest/uniswapv3Usage.md: -------------------------------------------------------------------------------- 1 | The `uniswapv3` command is a subcommand of the `loadtest` tool. It is meant to generate UniswapV3-like load against JSON-RPC endpoints. 2 | 3 | You can either chose to deploy the full UniswapV3 contract suite. 4 | 5 | ```sh 6 | polycli loadtest uniswapv3 7 | ``` 8 | 9 | Or to use pre-deployed contracts to speed up the process. 10 | 11 | ```bash 12 | polycli loadtest uniswapv3 \ 13 | --uniswap-factory-v3-address 0xc5f46e00822c828e1edcc12cf98b5a7b50c9e81b \ 14 | --uniswap-migrator-address 0x24951726c5d22a3569d5474a1e74734a09046cd9 \ 15 | --uniswap-multicall-address 0x0e695f36ade2a12abea51622e80f105e125d1d6e \ 16 | --uniswap-nft-descriptor-lib-address 0x23050ec03bb24308c788300428a8f9c247f28b25 \ 17 | --uniswap-nft-position-descriptor-address 0xea43847a98b671211b0e412849b69bbd7d53fd00 \ 18 | --uniswap-non-fungible-position-manager-address 0x58eabc23408fb7896b7ce943828cc00044786449 \ 19 | --uniswap-proxy-admin-address 0xdba55eb96288eac85974376b25b3c3f3d67399b7 \ 20 | --uniswap-quoter-v2-address 0x91464a00c4aae9dca6d503a2c24b1dfb8c279e50 \ 21 | --uniswap-staker-address 0xc87383ece9ee3ad3f5158998c4fc04833ba1336e \ 22 | --uniswap-swap-router-address 0x46096eb627d30125f9eaaeefeecaa4e237a04a97 \ 23 | --uniswap-tick-lens-address 0xc73dfb5055874cc7b1cf06ae83f7fe8f6facdb19 \ 24 | --uniswap-upgradeable-proxy-address 0x28656635b0ecd600801600475d61e3ec1534de6e \ 25 | --weth9-address 0x5570d4fd7cce73f0135536d83b8d49e6b77bb76c \ 26 | --uniswap-pool-token-0-address 0x1ce270d0380fbbead12371286aff578a1227d1d7 \ 27 | --uniswap-pool-token-1-address 0x060f7db3146f3d6748822fb4c69489a04b5f3278 28 | ``` 29 | 30 | Contracts are cloned from the different Uniswap repositories, compiled with a specific version of `solc` and go bindings are generated using `abigen`. To learn more about this process, make sure to check out `contracts/uniswapv3/README.org`. 31 | -------------------------------------------------------------------------------- /cmd/metricsToDash/usage.md: -------------------------------------------------------------------------------- 1 | Here is how you can use this command. 2 | 3 | ```bash 4 | $ polycli metrics-to-dash -i avail-metrics.txt -p avail. -t "Avail Devnet Dashboard" -T basedn -D devnet01.avail.polygon.private -T host -D validator-001 -s substrate_ -s sub_ -P true -S true 5 | 6 | $ polycli metrics-to-dash -i avail-light-metrics.txt -p avail_light. -t "Avail Light Devnet Dashboard" -T basedn -D devnet01.avail.polygon.private -T host -D validator-001 -s substrate_ -s sub_ -P true -S true 7 | ``` 8 | -------------------------------------------------------------------------------- /cmd/mnemonic/mnemonic.go: -------------------------------------------------------------------------------- 1 | package mnemonic 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/0xPolygon/polygon-cli/hdwallet" 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | var ( 11 | inputMnemonicWords *int 12 | inputMnemonicLang *string 13 | ) 14 | 15 | // mnemonicCmd represents the mnemonic command 16 | var MnemonicCmd = &cobra.Command{ 17 | Use: "mnemonic", 18 | Short: "Generate a BIP39 mnemonic seed.", 19 | Long: "", 20 | RunE: func(cmd *cobra.Command, args []string) error { 21 | mnemonic, err := hdwallet.NewMnemonic(*inputMnemonicWords, *inputMnemonicLang) 22 | if err != nil { 23 | return err 24 | } 25 | cmd.Println(mnemonic) 26 | return nil 27 | }, 28 | PreRunE: func(cmd *cobra.Command, args []string) error { 29 | if *inputMnemonicWords < 12 { 30 | return fmt.Errorf("the number of words in the mnemonic must be 12 or more. Given: %d", *inputMnemonicWords) 31 | } 32 | if *inputMnemonicWords > 24 { 33 | return fmt.Errorf("the number of words in the mnemonic must be 24 or less. Given: %d", *inputMnemonicWords) 34 | } 35 | if *inputMnemonicWords%3 != 0 { 36 | return fmt.Errorf("the number of words in the mnemonic must be a multiple of 3") 37 | } 38 | return nil 39 | 40 | }, 41 | } 42 | 43 | func init() { 44 | inputMnemonicWords = MnemonicCmd.PersistentFlags().Int("words", 24, "The number of words to use in the mnemonic") 45 | inputMnemonicLang = MnemonicCmd.PersistentFlags().String("language", "english", "Which language to use [ChineseSimplified, ChineseTraditional, Czech, English, French, Italian, Japanese, Korean, Spanish]") 46 | } 47 | -------------------------------------------------------------------------------- /cmd/monitor/usage.md: -------------------------------------------------------------------------------- 1 | ![GIF of `polycli monitor`](assets/monitor.gif) 2 | 3 | If you're using the terminal UI and you'd like to be able to select text for copying, you might need to use a modifier key. 4 | 5 | If you're experiencing missing blocks, try adjusting the `--batch-size` and `--interval` flags so that you poll for more blocks or more frequently. 6 | -------------------------------------------------------------------------------- /cmd/nodekey/usage.md: -------------------------------------------------------------------------------- 1 | The `nodekey` command is still in progress, but the idea is to have a 2 | simple command for generating a node key. 3 | 4 | Most clients will generate this on the fly, but if we want to store 5 | the key pair during an automated provisioning process, it's helpful to 6 | have the output be structured. 7 | 8 | ```bash 9 | # This will generate a secp256k1 key for devp2p protocol. 10 | $ polycli nodekey 11 | 12 | # Generate a networking keypair for libp2p. 13 | $ polycli nodekey --protocol libp2p 14 | 15 | # Generate a networking keypair for edge. 16 | $ polycli nodekey --protocol libp2p --key-type secp256k1 --marshal-protobuf 17 | ``` 18 | 19 | Generate an [ED25519](https://en.wikipedia.org/wiki/Curve25519) nodekey from a private key (in hex format). 20 | 21 | ```bash 22 | polycli nodekey --private-key 2a4ae8c4c250917781d38d95dafbb0abe87ae2c9aea02ed7c7524685358e49c2 | jq 23 | ``` 24 | 25 | ```json 26 | { 27 | "PublicKey": "93e8717f46b146ebfb99159eb13a5d044c191998656c8b79007b16051bb1ff762d09884e43783d898dd47f6220af040206cabbd45c9a26bb278a522c3d538a1f", 28 | "PrivateKey": "2a4ae8c4c250917781d38d95dafbb0abe87ae2c9aea02ed7c7524685358e49c2", 29 | "ENR": "enode://93e8717f46b146ebfb99159eb13a5d044c191998656c8b79007b16051bb1ff762d09884e43783d898dd47f6220af040206cabbd45c9a26bb278a522c3d538a1f@0.0.0.0:30303?discport=0" 30 | } 31 | ``` 32 | 33 | Generate an [Secp256k1](https://en.bitcoin.it/wiki/Secp256k1) nodekey from a private key (in hex format). 34 | 35 | ```bash 36 | polycli nodekey --private-key 2a4ae8c4c250917781d38d95dafbb0abe87ae2c9aea02ed7c7524685358e49c2 --key-type secp256k1 | jq 37 | ``` 38 | 39 | ```json 40 | { 41 | "address": "99AA9FC116C1E5E741E9EC18BD1FD232130A5C44", 42 | "pub_key": { 43 | "type": "comet/PubKeySecp256k1Uncompressed", 44 | "value": "BBNYN0nMJsgo0Fp3kVW85PRGBNe7Gdz1XBFuTWQ7D8FnKRb2JYO3i3FK2UiA5+gTSxYu1K66KdYjQYP1mOkH09g=" 45 | }, 46 | "priv_key": { 47 | "type": "comet/PrivKeySecp256k1Uncompressed", 48 | "value": "OP72E0D7GEi/4VySpolVudLW7uPJm+6PWEtFKJmvp1M=" 49 | } 50 | } 51 | ``` 52 | -------------------------------------------------------------------------------- /cmd/p2p/nodelist/nodelist.go: -------------------------------------------------------------------------------- 1 | package nodelist 2 | 3 | import ( 4 | "encoding/json" 5 | "os" 6 | 7 | "github.com/0xPolygon/polygon-cli/p2p/database" 8 | "github.com/spf13/cobra" 9 | ) 10 | 11 | const jsonIndent = " " 12 | 13 | type ( 14 | nodeListParams struct { 15 | ProjectID string 16 | OutputFile string 17 | Limit int 18 | } 19 | ) 20 | 21 | var ( 22 | inputNodeListParams nodeListParams 23 | ) 24 | 25 | var NodeListCmd = &cobra.Command{ 26 | Use: "nodelist [nodes.json]", 27 | Short: "Generate a node list to seed a node", 28 | Args: cobra.MinimumNArgs(1), 29 | PreRunE: func(cmd *cobra.Command, args []string) (err error) { 30 | inputNodeListParams.OutputFile = args[0] 31 | inputNodeListParams.ProjectID, err = cmd.Flags().GetString("project-id") 32 | return err 33 | }, 34 | RunE: func(cmd *cobra.Command, args []string) error { 35 | ctx := cmd.Context() 36 | 37 | db := database.NewDatastore(cmd.Context(), database.DatastoreOptions{ 38 | ProjectID: inputNodeListParams.ProjectID, 39 | }) 40 | 41 | nodes, err := db.NodeList(ctx, inputNodeListParams.Limit) 42 | if err != nil { 43 | return err 44 | } 45 | 46 | bytes, err := json.MarshalIndent(nodes, "", jsonIndent) 47 | if err != nil { 48 | return err 49 | } 50 | 51 | if err = os.WriteFile(inputNodeListParams.OutputFile, bytes, 0644); err != nil { 52 | return err 53 | } 54 | 55 | return nil 56 | }, 57 | } 58 | 59 | func init() { 60 | NodeListCmd.PersistentFlags().IntVarP(&inputNodeListParams.Limit, "limit", "l", 100, "Number of unique nodes to return") 61 | NodeListCmd.PersistentFlags().StringVarP(&inputNodeListParams.ProjectID, "project-id", "p", "", "GCP project ID") 62 | } 63 | -------------------------------------------------------------------------------- /cmd/p2p/p2p.go: -------------------------------------------------------------------------------- 1 | package p2p 2 | 3 | import ( 4 | "github.com/spf13/cobra" 5 | 6 | _ "embed" 7 | 8 | "github.com/0xPolygon/polygon-cli/cmd/p2p/crawl" 9 | "github.com/0xPolygon/polygon-cli/cmd/p2p/nodelist" 10 | "github.com/0xPolygon/polygon-cli/cmd/p2p/ping" 11 | "github.com/0xPolygon/polygon-cli/cmd/p2p/query" 12 | "github.com/0xPolygon/polygon-cli/cmd/p2p/sensor" 13 | ) 14 | 15 | //go:embed usage.md 16 | var usage string 17 | 18 | var P2pCmd = &cobra.Command{ 19 | Use: "p2p", 20 | Short: "Set of commands related to devp2p.", 21 | Long: usage, 22 | } 23 | 24 | func init() { 25 | P2pCmd.AddCommand(crawl.CrawlCmd) 26 | P2pCmd.AddCommand(nodelist.NodeListCmd) 27 | P2pCmd.AddCommand(ping.PingCmd) 28 | P2pCmd.AddCommand(sensor.SensorCmd) 29 | P2pCmd.AddCommand(query.QueryCmd) 30 | } 31 | -------------------------------------------------------------------------------- /cmd/parseethwallet/usage.md: -------------------------------------------------------------------------------- 1 | This function can take a geth style wallet file and extract the private key as hex. It can also do the opposite. 2 | 3 | This command takes the private key and imports it into a local keystore with no password. 4 | 5 | ```bash 6 | $ polycli parseethwallet --hexkey 42b6e34dc21598a807dc19d7784c71b2a7a01f6480dc6f58258f78e539f1a1fa 7 | 8 | $ cat UTC--2023-05-09T22-48-57.582848385Z--85da99c8a7c2c95964c8efd687e95e632fc533d6 | jq '.' 9 | { 10 | "address": "85da99c8a7c2c95964c8efd687e95e632fc533d6", 11 | "crypto": { 12 | "cipher": "aes-128-ctr", 13 | "ciphertext": "d0b4377a4ae5ebc9a5bef06ce4be99565d10cb0dedc2f7ff5aaa07ea68e7b597", 14 | "cipherparams": { 15 | "iv": "8ecd172ff7ace15ed5bc44ea89473d8e" 16 | }, 17 | "kdf": "scrypt", 18 | "kdfparams": { 19 | "dklen": 32, 20 | "n": 262144, 21 | "p": 1, 22 | "r": 8, 23 | "salt": "cd6ec772dc43225297412809feaae441d578642c6a67cabf4e29bcaf594f575b" 24 | }, 25 | "mac": "c992128ed466ad15a9648f4112af22929b95f511f065b12a80abcfb7e4d39a79" 26 | }, 27 | "id": "82af329d-2af5-41a6-ae6b-624f3e1c224b", 28 | "version": 3 29 | } 30 | ``` 31 | 32 | If we wanted to go the opposite direction, we could run a command like this. 33 | 34 | ```bash 35 | polycli parseethwallet --file /tmp/keystore/UTC--2023-05-09T22-48-57.582848385Z--85da99c8a7c2c95964c8efd687e95e632fc533d6 | jq '.' 36 | { 37 | "Address": "0x85da99c8a7c2c95964c8efd687e95e632fc533d6", 38 | "PublicKey": "507cf9a75e053cda6922467721ddb10412da9bec30620347d9529cc77fca24334a4cf59685be4a2fdeabf4e7753350e42d2d3a20250fd9dc554d226463c8a3d5", 39 | "PrivateKey": "42b6e34dc21598a807dc19d7784c71b2a7a01f6480dc6f58258f78e539f1a1fa" 40 | } 41 | ``` 42 | -------------------------------------------------------------------------------- /cmd/publish/output.go: -------------------------------------------------------------------------------- 1 | package publish 2 | 3 | import ( 4 | "fmt" 5 | "sync/atomic" 6 | "time" 7 | ) 8 | 9 | const ( 10 | InputDataSourceFile = "file" 11 | InputDataSourceArgs = "args" 12 | InputDataSourceStdin = "stdin" 13 | ) 14 | 15 | type inputDataSource string 16 | 17 | type output struct { 18 | InputDataSource inputDataSource 19 | InputDataCount atomic.Uint64 20 | ValidInputs atomic.Uint64 21 | InvalidInputs atomic.Uint64 22 | StartTime time.Time 23 | EndTime time.Time 24 | TxsSentSuccessfully atomic.Uint64 25 | TxsSentUnsuccessfully atomic.Uint64 26 | } 27 | 28 | func (s *output) Start() { 29 | s.StartTime = time.Now() 30 | } 31 | 32 | func (s *output) Stop() { 33 | s.EndTime = time.Now() 34 | } 35 | 36 | func (s *output) Print() { 37 | elapsed := s.EndTime.Sub(s.StartTime) 38 | elapsedSeconds := elapsed.Seconds() 39 | if elapsedSeconds == 0 { 40 | elapsedSeconds = 1 41 | } 42 | txSent := s.TxsSentSuccessfully.Load() + s.TxsSentUnsuccessfully.Load() 43 | txsSendPerSecond := 0.0 44 | if elapsedSeconds > 0.0001 { 45 | txsSendPerSecond = float64(txSent) / elapsedSeconds 46 | } 47 | successRatio := float64(0) 48 | if txSent > 0 { 49 | successRatio = float64(s.TxsSentSuccessfully.Load()) / float64(txSent) * 100 50 | } 51 | 52 | summaryString := fmt.Sprintf(`----------------------------------- 53 | Summary 54 | ----------------------------------- 55 | Concurrency: %d 56 | JobQueueSize: %d 57 | RateLimit: %d 58 | ----------------------------------- 59 | Input Data Source: %s 60 | Input Data Count: %d 61 | Valid Inputs: %d 62 | Invalid Inputs: %d 63 | ----------------------------------- 64 | Elapsed Time: %s 65 | Txs Sent: %d 66 | Txs Sent Per Second: %.2f 67 | Txs Sent Successfully: %d 68 | Txs Sent Unsuccessfully: %d 69 | Success Ratio: %.2f%% 70 | -----------------------------------`, 71 | *publishInputArgs.concurrency, 72 | *publishInputArgs.jobQueueSize, 73 | *publishInputArgs.rateLimit, 74 | 75 | s.InputDataSource, 76 | s.InputDataCount.Load(), 77 | s.ValidInputs.Load(), 78 | s.InvalidInputs.Load(), 79 | 80 | elapsed, 81 | txSent, 82 | txsSendPerSecond, 83 | s.TxsSentSuccessfully.Load(), 84 | s.TxsSentUnsuccessfully.Load(), 85 | successRatio) 86 | 87 | fmt.Println(summaryString) 88 | } 89 | -------------------------------------------------------------------------------- /cmd/publish/publish.md: -------------------------------------------------------------------------------- 1 | This command publish transactions with high-throughput. 2 | 3 | The command accepts a list of rlp hex encoded transactions that can be provided via a file, 4 | command line or stdin. 5 | 6 | Internally it uses a worker pool strategy that can be dimensioned via flag, so it can be adjusted 7 | for optimal performance depending on the hardware available. 8 | 9 | Since this command focus on high-throughput, please ensure the RPC will not rate-limit the requests. 10 | 11 | Below are some example of how to use it 12 | 13 | File: to use a file, set the file path using the --file flag 14 | ```bash 15 | polycli publish --rpc-url https://sepolia.drpc.org --file /home/tclemos/txs 16 | ``` 17 | 18 | Command Line: to use command line args, set as many args you need when calling the command 19 | ```bash 20 | polycli publish --rpc-url https://sepolia.drpc.org 0x000...001 0x000...002 0x000...003 0x000...004 ... 21 | ``` 22 | 23 | Stdin: to use std int, run the command without file or 0x args and then type one tx rlp per line 24 | ```bash 25 | polycli publish --rpc-url https://sepolia.drpc.org 26 | 27 | ``` 28 | -------------------------------------------------------------------------------- /cmd/publish/worker_pool.go: -------------------------------------------------------------------------------- 1 | package publish 2 | 3 | import ( 4 | "context" 5 | "sync" 6 | 7 | "github.com/rs/zerolog/log" 8 | ) 9 | 10 | type JobFn func(ctx context.Context, workerID uint64) 11 | 12 | // WorkerPool manages a pool of worker goroutines 13 | type WorkerPool struct { 14 | numWorkers uint64 15 | jobQueue chan JobFn 16 | wg sync.WaitGroup 17 | } 18 | 19 | // NewWorkerPool creates a new worker pool 20 | func NewWorkerPool(numWorkers, queueSize uint64) *WorkerPool { 21 | return &WorkerPool{ 22 | numWorkers: numWorkers, 23 | jobQueue: make(chan JobFn, queueSize), 24 | wg: sync.WaitGroup{}, 25 | } 26 | } 27 | 28 | // Start starts the worker pool 29 | func (wp *WorkerPool) Start(ctx context.Context) { 30 | for i := range wp.numWorkers { 31 | wp.wg.Add(1) 32 | go wp.worker(ctx, i) 33 | } 34 | } 35 | 36 | // Stop stops the worker pool and waits for all workers to finish 37 | func (wp *WorkerPool) Stop() { 38 | close(wp.jobQueue) 39 | wp.wg.Wait() 40 | } 41 | 42 | // SubmitJob submits a job to the worker pool 43 | func (wp *WorkerPool) SubmitJob(job JobFn) { 44 | wp.jobQueue <- job 45 | } 46 | 47 | // worker is a worker goroutine that processes jobs 48 | func (wp *WorkerPool) worker(ctx context.Context, workerID uint64) { 49 | defer wp.wg.Done() 50 | for job := range wp.jobQueue { 51 | safeJob(ctx, workerID, job) 52 | } 53 | } 54 | 55 | // Executes the job safely and recovers in case it panics 56 | func safeJob(ctx context.Context, workerID uint64, job JobFn) { 57 | defer func() { 58 | if r := recover(); r != nil { 59 | log.Error().Msgf("Worker panicked: %v", r) 60 | } 61 | }() 62 | job(ctx, workerID) 63 | } 64 | -------------------------------------------------------------------------------- /cmd/rpcfuzz/README.org: -------------------------------------------------------------------------------- 1 | Current list of RPCs: 2 | 3 | - [X] ~debug_getBadBlocks~ 4 | - [X] ~debug_getRawBlock~ 5 | - [X] ~debug_getRawHeader~ 6 | - [X] ~debug_getRawReceipts~ 7 | - [X] ~debug_getRawTransaction~ 8 | - [X] ~debug_traceBlockByHash~ 9 | - [X] ~debug_traceBlockByNumber~ 10 | - [X] ~debug_traceBlock~ 11 | - [X] ~debug_traceCall~ 12 | - [X] ~debug_traceTransaction~ 13 | - [ ] ~engine_exchangeCapabilities~ 14 | - [ ] ~engine_exchangeTransitionConfigurationV1~ 15 | - [ ] ~engine_forkchoiceUpdatedV1~ 16 | - [ ] ~engine_forkchoiceUpdatedV2~ 17 | - [ ] ~engine_getPayloadBodiesByHashV1~ 18 | - [ ] ~engine_getPayloadBodiesByRangeV1~ 19 | - [ ] ~engine_getPayloadV1~ 20 | - [ ] ~engine_getPayloadV2~ 21 | - [ ] ~engine_newPayloadV1~ 22 | - [ ] ~engine_newPayloadV2~ 23 | - [X] ~eth_createAccessList~ 24 | - [X] ~eth_feeHistory~ 25 | - [X] ~eth_getProof~ 26 | - [X] ~eth_maxPriorityFeePerGas~ 27 | - [X] ~eth_accounts~ 28 | - [X] ~eth_blockNumber~ 29 | - [X] ~eth_call~ 30 | - [X] ~eth_chainId~ 31 | - [X] ~eth_coinbase~ 32 | - [X] ~eth_estimateGas~ 33 | - [X] ~eth_gasPrice~ 34 | - [X] ~eth_getBalance~ 35 | - [X] ~eth_getBlockByHash~ 36 | - [X] ~eth_getBlockByNumber~ 37 | - [X] ~eth_getBlockTransactionCountByHash~ 38 | - [X] ~eth_getBlockTransactionCountByNumber~ 39 | - [X] ~eth_getCode~ 40 | - [X] ~eth_getFilterChanges~ 41 | - [X] ~eth_getFilterLogs~ 42 | - [X] ~eth_getLogs~ 43 | - [X] ~eth_getStorageAt~ 44 | - [X] ~eth_getTransactionByBlockHashAndIndex~ 45 | - [X] ~eth_getTransactionByBlockNumberAndIndex~ 46 | - [X] ~eth_getTransactionByHash~ 47 | - [X] ~eth_getTransactionCount~ 48 | - [X] ~eth_getTransactionReceipt~ 49 | - [X] ~eth_getUncleCountByBlockHash~ 50 | - [X] ~eth_getUncleCountByBlockNumber~ 51 | - [X] ~eth_getWork~ 52 | - [X] ~eth_hashrate~ 53 | - [X] ~eth_mining~ 54 | - [X] ~eth_newBlockFilter~ 55 | - [X] ~eth_newFilter~ 56 | - [X] ~eth_newPendingTransactionFilter~ 57 | - [X] ~eth_sendRawTransaction~ 58 | - [X] ~eth_sendTransaction~ 59 | - [X] ~eth_signTransaction~ 60 | - [X] ~eth_sign~ 61 | - [X] ~eth_submitHashrate~ 62 | - [X] ~eth_submitWork~ 63 | - [X] ~eth_syncing~ 64 | - [X] ~eth_uninstallFilter~ 65 | 66 | TODO: 67 | - Add post merge tags 68 | - latest 69 | - earliest 70 | - pending 71 | - safe 72 | - finalized 73 | - Add batch calls to confirm batch behaviors 74 | - Add nonce behavioral issues 75 | - Replacement 76 | - Duplicate 77 | - Too low 78 | - Huge gap 79 | -------------------------------------------------------------------------------- /cmd/signer/createCmdUsage.md: -------------------------------------------------------------------------------- 1 | The create subcommand will create a new key pair. By default, a hex private key will be written to `stdout`. 2 | ```bash 3 | polycli signer create > private-key.txt 4 | ``` 5 | 6 | If you need to work with a go-ethereum style keystore, a key can be added by setting a `--keystore` directory. When you run this command, you'll need to specify a password to encrypt the private key. 7 | 8 | ```bash 9 | polycli signer create --keystore /tmp/keystore 10 | ``` 11 | 12 | Polycli also has basic support for KMS with GCP. Creating a new key in the cloud can be accomplished with a command like this 13 | 14 | ```bash 15 | # polycli assumes that there is default login that's been done already 16 | gcloud auth application-default login 17 | polycli signer create --kms GCP --gcp-project-id prj-polygonlabs-devtools-dev --key-id jhilliard-trash 18 | ``` 19 | -------------------------------------------------------------------------------- /cmd/signer/importCmdUsage.md: -------------------------------------------------------------------------------- 1 | It's possible to import a simple hex encoded private key into a local 2 | keystore or as a crypto key version in GCP KMS. 3 | 4 | In order to import into a local keystore, a command like this could be used: 5 | 6 | ```bash 7 | polycli signer import --keystore /tmp/keystore --private-key cf42d151cec45693f2ac1201e803b056c5f9e2e5d1af627ce41ab3b6faceda25 8 | ``` 9 | 10 | ### Importing into GCP KMS 11 | 12 | Importing into GCP KMS is a little bit more complicated. In order to run the import, a command like this would be used: 13 | 14 | ```bash 15 | polycli signer import --private-key 42b6e34dc21598a807dc19d7784c71b2a7a01f6480dc6f58258f78e539f1a1fa --kms gcp --gcp-project-id prj-polygonlabs-devtools-dev --key-id jhilliard-code-quality --gcp-import-job-id test-import-job 16 | ``` 17 | 18 | There are a few things going on here: 19 | 20 | 1. We're specifying a `--private-key` that's hex encoded. That's the only format that `import` accepts at this time. 21 | 2. We're using `--kms gcp` which tell polycli that we want to use gcp kms as our backend 22 | 3. We've specified `--gcp-project-id` which names a test project that we're using. We've left out `--gcp-location` and `--gcp-keyring-id` which means we're using the defaults. 23 | 4. We've set `--gcp-import-job-id test-import-job` which names a job that will be used to import the key. Basically GCP will give us a public key that we use to encrypt our key for importing 24 | 25 | The `--key-id` is also important. This will set the name of the key that's going to be imported. Note, the key-id must have already been created in order for import to work. When we're doing the import, we're actually importing a new version of the key that already exists. For the time being, the `signer import` command will not create the first version of the key for you. 26 | -------------------------------------------------------------------------------- /cmd/signer/listCmdUsage.md: -------------------------------------------------------------------------------- 1 | After creating a few keys in the keystore or KMS, it's useful just to be able to list the keys. If you're using a keystore, the accounts can be listed using this command: 2 | 3 | ```bash 4 | polycli signer list --keystore /tmp/keystore 5 | ``` 6 | 7 | In the case of GCP KMS, the keyring will need to be provided and the keys can be listed with this command: 8 | 9 | ```bash 10 | polycli signer list --kms GCP --gcp-project-id prj-polygonlabs-devtools-dev --gcp-keyring-id polycli-keyring 11 | ``` 12 | -------------------------------------------------------------------------------- /cmd/signer/usage.md: -------------------------------------------------------------------------------- 1 | This command is meant to allow for easy creation of signed transactions. A raw transaction can then be published with a call to 2 | [`eth_sendRawTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction) or using [`cast publish`](https://book.getfoundry.sh/reference/cast/cast-publish). 3 | -------------------------------------------------------------------------------- /cmd/ulxly/BridgeWETHMessageUsage.md: -------------------------------------------------------------------------------- 1 | This command is not used very often but can be used on L2 networks that have a gas token. 2 | 3 | ```solidity 4 | /** 5 | * @notice Bridge message and send ETH value 6 | * note User/UI must be aware of the existing/available networks when choosing the destination network 7 | * @param destinationNetwork Network destination 8 | * @param destinationAddress Address destination 9 | * @param amountWETH Amount of WETH tokens 10 | * @param forceUpdateGlobalExitRoot Indicates if the new global exit root is updated or not 11 | * @param metadata Message metadata 12 | */ 13 | function bridgeMessageWETH( 14 | uint32 destinationNetwork, 15 | address destinationAddress, 16 | uint256 amountWETH, 17 | bool forceUpdateGlobalExitRoot, 18 | bytes calldata metadata 19 | ) external ifNotEmergencyState { 20 | ``` 21 | [Here](https://github.com/0xPolygonHermez/zkevm-contracts/blob/c8659e6282340de7bdb8fdbf7924a9bd2996bc98/contracts/v2/PolygonZkEVMBridgeV2.sol#L352-L367) is the source code that corresponds to this interface. 22 | 23 | Assuming the network is configured with a gas token, you could call this method like this: 24 | 25 | ```bash 26 | polycli ulxly bridge weth \ 27 | --bridge-address 0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582 \ 28 | --destination-address 0x3878Cff9d621064d393EEF92bF1e12A944c5ba84 \ 29 | --private-key 0x32430699cd4f46ab2422f1df4ad6546811be20c9725544e99253a887e971f92b \ 30 | --value 123456 \ 31 | --destination-network 1 \ 32 | --rpc-url http://l2-rpc-url.invalid \ 33 | --token-address $WETH_ADDRESS 34 | ``` 35 | 36 | -------------------------------------------------------------------------------- /cmd/ulxly/balanceTreeUsage.md: -------------------------------------------------------------------------------- 1 | This command will attempt to compute the root of the balnace tree based on the bridge 2 | events that are provided. 3 | 4 | Example usage: 5 | 6 | ```bash 7 | polycli ulxly compute-balance-tree \ 8 | --l2-claims-file l2-claims-0-to-11454081.ndjson \ 9 | --l2-deposits-file l2-deposits-0-to-11454081.ndjson \ 10 | --l2-network-id 3 11 | --bridge-address 0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582 \ 12 | --rpc-url http://localhost:8213 | jq '.' 13 | ``` 14 | 15 | In this case we are assuming we have two files 16 | `l2-claims-0-to-11454081.ndjson` and `l2-deposits-0-to-11454081.ndjson` that would have been generated 17 | with a call to `polycli ulxly get-deposits` and `polycli ulxly get-claims` pointing to each network. The output will be the 18 | root of the tree for the provided deposits and claims. 19 | 20 | This is the response from polycli: 21 | 22 | ```json 23 | { 24 | "root": "0x4516ca2a793b8e20f56ec6ba8ca6033a672330670a3772f76f2ade9bc2125150"", 25 | } 26 | ``` 27 | 28 | Note: more info https://github.com/BrianSeong99/Agglayer_PessimisticProof_Benchmark?tab=readme-ov-file#architecture-of-pessimistic-proof -------------------------------------------------------------------------------- /cmd/ulxly/claimGetUsage.md: -------------------------------------------------------------------------------- 1 | This command will attempt to scan a range of blocks and look for uLxLy 2 | Claim Events. This is the specific signature that we're interested 3 | in: 4 | 5 | ```solidity 6 | /** 7 | * @dev Emitted when a claim is done from another network 8 | */ 9 | event ClaimEvent( 10 | uint256 globalIndex, 11 | uint32 originNetwork, 12 | address originAddress, 13 | address destinationAddress, 14 | uint256 amount 15 | ); 16 | ``` 17 | 18 | If you're looking at the raw topics from on chain or in an explorer, this is the associated value: 19 | 20 | `0x1df3f2a973a00d6635911755c260704e95e8a5876997546798770f76396fda4d` 21 | 22 | Each event that we counter will be parsed and written as JSON to 23 | stdout. Example usage: 24 | 25 | ```bash 26 | polycli ulxly get-claims \ 27 | --bridge-address 0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582 \ 28 | --rpc-url https://eth-sepolia.g.alchemy.com/v2/demo \ 29 | --from-block 4880876 \ 30 | --to-block 6028159 \ 31 | --filter-size 9999 > cardona-4880876-to-6028159.ndjson 32 | ``` 33 | 34 | This command will look for claim events from block `4880876` to 35 | block `6028159` in increments of `9999` blocks at a time for the 36 | contract address `0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582`. The 37 | output will be written as newline delimited JSON. 38 | 39 | This command is very specific for the ulxly bridge, and it's meant to 40 | serve as the input to the proof command. 41 | 42 | 43 | -------------------------------------------------------------------------------- /cmd/ulxly/depositGetUsage.md: -------------------------------------------------------------------------------- 1 | This command will attempt to scan a range of blocks and look for uLxLy 2 | Bridge Events. This is the specific signature that we're interested 3 | in: 4 | 5 | ```solidity 6 | /** 7 | * @dev Emitted when bridge assets or messages to another network 8 | */ 9 | event BridgeEvent( 10 | uint8 leafType, 11 | uint32 originNetwork, 12 | address originAddress, 13 | uint32 destinationNetwork, 14 | address destinationAddress, 15 | uint256 amount, 16 | bytes metadata, 17 | uint32 depositCount 18 | ); 19 | 20 | ``` 21 | 22 | If you're looking at the raw topics from on chain or in an explorer, this is the associated value: 23 | 24 | `0x501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b` 25 | 26 | Each event that we counter will be parsed and written as JSON to 27 | stdout. Example usage: 28 | 29 | ```bash 30 | polycli ulxly get-deposits \ 31 | --bridge-address 0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582 \ 32 | --rpc-url https://eth-sepolia.g.alchemy.com/v2/demo \ 33 | --from-block 4880876 \ 34 | --to-block 6028159 \ 35 | --filter-size 9999 > cardona-4880876-to-6028159.ndjson 36 | ``` 37 | 38 | This command will look for bridge events from block `4880876` to 39 | block `6028159` in increments of `9999` blocks at a time for the 40 | contract address `0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582`. The 41 | output will be written as newline delimited JSON. 42 | 43 | This command is very specific for the ulxly bridge, and it's meant to 44 | serve as the input to the proof command. 45 | 46 | 47 | -------------------------------------------------------------------------------- /cmd/ulxly/nullifierAndBalanceTreeUsage.md: -------------------------------------------------------------------------------- 1 | This command will attempt to compute the root of the balnace tree based on the bridge 2 | events that are provided. 3 | 4 | Example usage: 5 | 6 | ```bash 7 | polycli ulxly compute-balance-nullifier-tree \ 8 | --l2-claims-file l2-claim-0-to-11454081.ndjson \ 9 | --l2-deposits-file l2-deposits-0-to-11454081.ndjson \ 10 | --l2-network-id 3 \ 11 | --bridge-address 0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582 \ 12 | --rpc-url http://localhost:8213 | jq '.' 13 | ``` 14 | 15 | In this case we are assuming we have two files 16 | `l2-claim-0-to-11454081.ndjson` and `l2-deposits-0-to-11454081.ndjson` that would have been generated 17 | with a call to `polycli ulxly get-deposits` and `polycli ulxly get-claims` pointing to each network. 18 | The output will be the roots of the trees for the provided deposits and claims. 19 | 20 | This is the response from polycli: 21 | 22 | ```json 23 | { 24 | "balanceTreeRoot": "0x089ed8cce8639374a1bbd2480df7ed5224ea715b7521e1e2de549a6def791757", 25 | "nullifierTreeRoot": "0x7f075c4345694cc79a573890d7ec6222534cf470355611801104be0c8bf972c4", 26 | "initPessimisticRoot": "0x4358f03557f5d34ab419bee9919b4858c9d9bdedbe8e7ce7fb78ff9c4bc65676" 27 | } 28 | ``` 29 | 30 | Note: more info https://github.com/BrianSeong99/Agglayer_PessimisticProof_Benchmark?tab=readme-ov-file#architecture-of-pessimistic-proof -------------------------------------------------------------------------------- /cmd/ulxly/nullifierTreeUsage.md: -------------------------------------------------------------------------------- 1 | This command will attempt to computethe nullifierTree based on the claims that are provided. 2 | 3 | Example usage: 4 | 5 | ```bash 6 | polycli ulxly compute-nullifier-tree \ 7 | --file-name claims-cardona-4880876-to-6028159.ndjson | jq '.' 8 | ``` 9 | 10 | In this case we are assuming we have a file 11 | `claims-cardona-4880876-to-6028159.ndjson` that would have been generated 12 | with a call to `polycli ulxly get-claims`. The output will be the 13 | claims necessary to compute the nullifier tree. 14 | 15 | This is the response from polycli: 16 | 17 | ```json 18 | { 19 | "root": "0x4516ca2a793b8e20f56ec6ba8ca6033a672330670a3772f76f2ade9bc2125150"", 20 | } 21 | ``` 22 | 23 | Note: more info https://github.com/BrianSeong99/Agglayer_PessimisticProof_Benchmark?tab=readme-ov-file#architecture-of-pessimistic-proof -------------------------------------------------------------------------------- /cmd/ulxly/testvectors/vectors.go: -------------------------------------------------------------------------------- 1 | package vectors 2 | 3 | import ( 4 | "github.com/ethereum/go-ethereum/common" 5 | ) 6 | 7 | type NullifierLeaf struct { 8 | NetworkID uint32 `json:"network_id"` 9 | Index uint32 `json:"let_index"` 10 | } 11 | 12 | type BalanceLeaf struct { 13 | OriginNetwork uint32 `json:"origin_network"` 14 | OriginTokenAddress common.Address `json:"origin_token_address"` 15 | } 16 | 17 | type UpdatedLeaf[T BalanceLeaf | NullifierLeaf] struct { 18 | Key T `json:"key"` 19 | Value common.Hash `json:"value"` 20 | Path string `json:"path"` 21 | } 22 | 23 | type Transition[T BalanceLeaf | NullifierLeaf] struct { 24 | PrevRoot common.Hash `json:"prev_root"` 25 | NewRoot common.Hash `json:"new_root"` 26 | UpdateLeaf UpdatedLeaf[T] `json:"updated_leaf"` 27 | } 28 | 29 | type TestVector[T BalanceLeaf | NullifierLeaf] struct { 30 | Transitions []Transition[T] `json:"transitions"` 31 | } 32 | -------------------------------------------------------------------------------- /cmd/ulxly/tree-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0xPolygon/polygon-cli/edb6d4b320582f7a06aee54210a8aa93dec430ee/cmd/ulxly/tree-diagram.png -------------------------------------------------------------------------------- /cmd/ulxly/verifyBatchesGetUsage.md: -------------------------------------------------------------------------------- 1 | This command will attempt to scan a range of blocks and look for verify batch Events. This is the specific signature that we're interested 2 | in: 3 | 4 | ```solidity 5 | /** 6 | * @dev Emitted when the trusted aggregator verifies batches 7 | */ 8 | event VerifyBatchesTrustedAggregator( 9 | uint32 indexed rollupID, 10 | uint64 numBatch, 11 | bytes32 stateRoot, 12 | bytes32 exitRoot, 13 | address indexed aggregator 14 | ); 15 | 16 | ``` 17 | 18 | If you're looking at the raw topics from on chain or in an explorer, this is the associated value: 19 | 20 | `0xd1ec3a1216f08b6eff72e169ceb548b782db18a6614852618d86bb19f3f9b0d3` 21 | 22 | Each event that we counter will be parsed and written as JSON to 23 | stdout. Example usage: 24 | 25 | ```bash 26 | polycli ulxly get-verify-batches \ 27 | --rollup-manager-address 0x32d33d5137a7cffb54c5bf8371172bcec5f310ff \ 28 | --rpc-url https://eth-sepolia.g.alchemy.com/v2/demo \ 29 | --from-block 4880876 \ 30 | --to-block 6028159 \ 31 | --filter-size 9999 > verify-batches-cardona-4880876-to-6028159.ndjson 32 | ``` 33 | 34 | This command will look for verify batch events from block `4880876` to 35 | block `6028159` in increments of `9999` blocks at a time for the 36 | contract address `0x32d33d5137a7cffb54c5bf8371172bcec5f310ff`. The 37 | output will be written as newline delimited JSON. 38 | 39 | This command is very specific for the ulxly bridge, and it's meant to 40 | serve as the input to the rollup-proof command. 41 | 42 | 43 | -------------------------------------------------------------------------------- /cmd/version/version.go: -------------------------------------------------------------------------------- 1 | package version 2 | 3 | import ( 4 | "github.com/spf13/cobra" 5 | ) 6 | 7 | var ( 8 | Version = "dev" 9 | Commit = "none" 10 | Date = "unknown" 11 | BuiltBy = "unknown" 12 | ) 13 | 14 | // versionCmd represents the version command 15 | var VersionCmd = &cobra.Command{ 16 | Use: "version", 17 | Short: "Get the current version of this application", 18 | Long: `Nothing fancy. Print the version of this application`, 19 | Run: func(cmd *cobra.Command, args []string) { 20 | cmd.Printf("Polygon CLI Version %s\n", Version) 21 | }, 22 | } 23 | -------------------------------------------------------------------------------- /cmd/wallet/usage.md: -------------------------------------------------------------------------------- 1 | This command is meant to simplify the operations of creating 2 | wallets. This command can take a seed phrase and spit out child 3 | accounts or generate new accounts along with a seed phrase. It can 4 | generate portable wallets to be used across ETH, BTC, PoS, Substrate, 5 | etc. 6 | 7 | In the example, we're generating a wallet with a few flags that are 8 | used to configure how many wallets are generated and how the seed 9 | phrase is used to generate the wallets. 10 | 11 | ```bash 12 | $ polycli wallet create --raw-entropy --root-only --words 15 --language english 13 | ``` 14 | 15 | In addition to generating wallets with new mnemonics, you can use a 16 | known mnemonic to generate wallets. **Caution** entering your seed 17 | phrase in the command line should only be done for test 18 | mnemonics. Never do this with a real seed phrase. 19 | 20 | The example below is a test vector from Substrate. 21 | 22 | [BIP-0039](https://github.com/paritytech/substrate-bip39/blob/eef2f86337d2dab075806c12948e8a098aa59d59/src/lib.rs#L74) where the expected seed is `44e9d125f037ac1d51f0a7d3649689d422c2af8b1ec8e00d71db4d7bf6d127e33f50c3d5c84fa3e5399c72d6cbbbbc4a49bf76f76d952f479d74655a2ef2d453` 23 | 24 | ```bash 25 | $ polycli wallet inspect --raw-entropy --root-only --language english --password "Substrate" --mnemonic "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about" 26 | ``` 27 | 28 | This command also leverages the BIP-0032 library for hierarchically derived wallets. 29 | 30 | ```bash 31 | $ polycli wallet create --path "m/44'/0'/0'" --addresses 5 32 | ``` 33 | -------------------------------------------------------------------------------- /cmd/wrapcontract/usage.md: -------------------------------------------------------------------------------- 1 | This command takes the runtime bytecode, the bytecode deployed on-chain, as input and converts it into creation bytecode, the bytecode used to create the contract 2 | 3 | ```bash 4 | $ polycli wrap-contract 69602a60005260206000f3600052600a6016f3 5 | $ echo 69602a60005260206000f3600052600a6016f3 | polycli wrap-contract 6 | 7 | ``` 8 | 9 | You can also provide a path to a file, and the bytecode while be read from there. 10 | 11 | ```bash 12 | $ polycli wrap-contract bytecode.txt 13 | $ polycli wrap-contract ../bytecode.txt 14 | $ polycli wrap-contract /tmp/bytecode.txt 15 | $ echo /tmp/bytecode.txt | polycli wrap-contract 16 | ``` 17 | 18 | Additionally, you can provide storage for the contract in JSON 19 | ```bash 20 | $ polycli wrap-contract 0x4455 --storage '{"0x01":"0x0034"}' 21 | $ polycli wrap-contract 0x4455 --storage '{"0x01":"0x0034", "0x02": "0xFF"}' 22 | $ echo 69602a60005260206000f3600052600a6016f3 | polycli wrap-contract --storage '{"0x01":"0x0034", "0x02": "0xFF"}' 23 | ``` 24 | 25 | The resulting bytecode will be formatted this way: 26 | 27 | 0x?? // storage initialization code if any 28 | 63?? // PUSH4 to indicate the size of the data that should be copied into memory 29 | 63?? // PUSH4 to indicate the offset in the call data to start the copy 30 | 6000 // PUSH1 00 to indicate the destination offset in memory 31 | 39 // CODECOPY 32 | 63?? // PUSH4 to indicate the size of the data to be returned from memory 33 | 6000 // PUSH1 00 to indicate that it starts from offset 0 34 | F3 // RETURN 35 | ??, // Deployed Bytecode 36 | -------------------------------------------------------------------------------- /contracts/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiler files 2 | cache/ 3 | out/ 4 | 5 | # Ignores development broadcast logs 6 | !/broadcast 7 | /broadcast/*/31337/ 8 | /broadcast/**/dry-run/ 9 | 10 | # Docs 11 | docs/ 12 | 13 | # Dotenv file 14 | .env 15 | -------------------------------------------------------------------------------- /contracts/foundry.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | src = "src" 3 | out = "out" 4 | libs = ["lib"] 5 | remappings = [ 6 | '@openzeppelin/=lib/openzeppelin-contracts/contracts', 7 | ] 8 | solc_version = "0.8.23" # https://github.com/ethereum/solidity/releases 9 | 10 | # default profile with Yul optimiser disabled. 11 | [profile.default.optimizer_details] 12 | yul = false 13 | 14 | # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options 15 | -------------------------------------------------------------------------------- /contracts/src/asm/blockhash-gas-loop.easm: -------------------------------------------------------------------------------- 1 | ;; Push a value on the stack for tracking the number of iterations that we've done 2 | PUSH 0x0 3 | 4 | ;; create a jump dest and label for looping 5 | loop: 6 | 7 | ;; increment the counter 8 | PUSH 0x1 9 | ADD 10 | 11 | ;; Copy the counter to be passed to blockhash 12 | DUP1 13 | 14 | ;; Get the hash of the current counter and discard it 15 | BLOCKHASH 16 | POP 17 | 18 | ;; If the amount of Gas left is less than 21,000, we're going to STOP 19 | PUSH 0x5208 20 | GAS 21 | GT 22 | 23 | ;; push the jump destination for looping 24 | PUSH @loop 25 | 26 | JUMPI 27 | 28 | ;; reach here if we're low on gas 29 | STOP 30 | -------------------------------------------------------------------------------- /contracts/src/asm/delegate-call-loop.easm: -------------------------------------------------------------------------------- 1 | ;; Push a value on the stack for tracking the number of iterations that we've done 2 | PUSH 0x00000000 3 | 4 | ;; create a jump dest and label for looping 5 | loop: 6 | 7 | ;; increment the counter 8 | PUSH 0x1 9 | ADD 10 | 11 | 12 | 13 | ;; 0 retsize should be fine 14 | PUSH 0x00 15 | ;; Same with ret offset.. no need to pass data 16 | DUP1 17 | ;; Same with arg size 18 | DUP1 19 | ;; Same with arg offset 20 | DUP1 21 | DUP1 22 | ;; push the address of the contract that we want to call 23 | PUSH 0x0000000000000000000000000000000000000001 24 | ;; PUSH 0xd2581362bbd7c8ad4ab412068198cde1a8a9bd3b 25 | ;; how much gas to send? let's do about 450K 26 | PUSH 0x70000 27 | 28 | CALL 29 | 30 | ;; ignore the return for now 31 | POP 32 | 33 | 34 | 35 | 36 | 37 | 38 | ;; Get the counter and compare to our arbitrary limit 39 | DUP1 40 | 41 | ;; 18 Gas per loop 42 | PUSH 0x65B9A 43 | GT 44 | 45 | ;; push the jump destination for looping 46 | PUSH @loop 47 | JUMPI 48 | 49 | ;; drop the iterator 50 | POP 51 | 52 | STOP 53 | 54 | 55 | -------------------------------------------------------------------------------- /contracts/src/asm/deploy-call-loop.easm: -------------------------------------------------------------------------------- 1 | ;; Push a value on the stack for tracking the number of iterations that we've done 2 | PUSH 0x0 3 | 4 | ;; create a jump dest and label for looping 5 | loop: 6 | 7 | ;; increment the counter 8 | PUSH 0x1 9 | ADD 10 | 11 | ;; Copy the counter to be passed to as a salt 12 | DUP1 13 | 14 | 15 | PUSH 0x60005b6001018040506152085a1163000000025700 16 | PUSH 0x00 17 | MSTORE 18 | 19 | 20 | PUSH 21 21 | PUSH 0x0 22 | PUSH 0x0 23 | CREATE2 24 | 25 | 26 | ;; retOffset 27 | PUSH 10 28 | PUSH 0 29 | PUSH 0 30 | PUSH 0 31 | ;; retSize 32 | PUSH 0 33 | SWAP5 34 | 35 | GAS 36 | 37 | CALL 38 | 39 | POP 40 | 41 | 42 | ;; If the amount of Gas left is less than 32K we're going to STOP 43 | PUSH 0x8000 44 | GAS 45 | GT 46 | 47 | ;; push the jump destination for looping 48 | PUSH @loop 49 | 50 | JUMPI 51 | 52 | ;; reach here if we're low on gas 53 | STOP 54 | -------------------------------------------------------------------------------- /contracts/src/asm/deploy-header.easm: -------------------------------------------------------------------------------- 1 | ;; 0x12 is the number of instructions in our runtime code 2 | PUSH 0x68 3 | ;; this is the position of the runtime code in the paylod 4 | PUSH 0x0C 5 | ;; this is the slot where we'll store this data 6 | PUSH 0x00 7 | CODECOPY 8 | 9 | ;; this is the length of the runtime code again 10 | PUSH 0x68 11 | ;; the slot 12 | PUSH 0x00 13 | 14 | RETURN 15 | -------------------------------------------------------------------------------- /contracts/src/asm/deploy.easm: -------------------------------------------------------------------------------- 1 | ;; Push a value on the stack for tracking the number of iterations that we've done 2 | PUSH 0x0 3 | 4 | ;; create a jump dest and label for looping 5 | loop: 6 | 7 | ;; increment the counter 8 | PUSH 0x1 9 | ADD 10 | 11 | ;; Copy the counter to be passed to as a salt 12 | DUP1 13 | 14 | 15 | PUSH 0x60005b6001018040506152085a1163000000025700 16 | PUSH 0x00 17 | MSTORE 18 | 19 | 20 | PUSH 21 21 | PUSH 0x0 22 | PUSH 0x0 23 | CREATE2 24 | 25 | POP 26 | 27 | 28 | 29 | ;; If the amount of Gas left is less than 32K we're going to STOP 30 | PUSH 0x8000 31 | GAS 32 | GT 33 | 34 | ;; push the jump destination for looping 35 | PUSH @loop 36 | 37 | JUMPI 38 | 39 | ;; reach here if we're low on gas 40 | STOP 41 | -------------------------------------------------------------------------------- /contracts/src/asm/fib-nostore.easm: -------------------------------------------------------------------------------- 1 | ;;; This is a memory only fibonacci implementation. The previous 2 | ;;; implementation was using storage slots to store the first ~300 fib 3 | ;;; numbers so that after the contract was deployed the storage slots 4 | ;;; would have different fib numbers. That's a bit expensive and 5 | ;;; pointless since I have no functions and no one can see the storage 6 | ;;; slots easily. So in this case I'm just going to use memory and 7 | ;;; return memory space with this data in it. 8 | 9 | ;; Value of 0 at offset 0 10 | PUSH 0x0 11 | PUSH 0x0 12 | MSTORE 13 | 14 | ;; Value of 1 at offset 32. Since each number is 32 bytes 15 | ;; every number will increment the offset by 32 bytes 16 | PUSH 0x1 17 | PUSH 0x20 18 | MSTORE 19 | 20 | ;; We're now 64 bytes in. The first two numbers are hard 21 | ;; coded, the of the code a loop to generate more numbers 22 | PUSH 0x40 23 | loop: 24 | ;; Duplicate the current offset so that we can use it 25 | DUP1 26 | 27 | ;; Subtract 32 from the current offset (f - 1) 28 | PUSH 0x20 29 | SWAP1 30 | SUB 31 | 32 | ;; Duplicate the previous number so that we can use it again 33 | DUP1 34 | 35 | ;; Subtract 32 from the current offset (f - 2) 36 | PUSH 0x20 37 | SWAP1 38 | SUB 39 | 40 | ;; Load the values of (f - 1) and (f - 2) from memory and add them together 41 | MLOAD 42 | SWAP1 43 | MLOAD 44 | ADD 45 | 46 | ;; Store the current offset and latest fib in memory 47 | DUP2 48 | MSTORE 49 | 50 | ;; increment the offset 51 | PUSH 0x20 52 | ADD 53 | 54 | ;; Compare the current offset to 370*32. This is approximately the biggest number we can store natively work on in our instructions. The 370th fib number is 55 | ;; 94611056096305838013295371573764256526437182762229865607320618320601813254535 56 | ;; d12bf5c7f45a49f54fdf4e79a339eb28e1cc739052cbfa4bcc70eb22d7c28187 57 | ;; After this number the ADD operation will start overflowing, so we need to stop 58 | DUP1 59 | PUSH 0x2E60 60 | GT 61 | 62 | PUSH @loop 63 | JUMPI 64 | 65 | ;; we're done... drop the iterator 66 | POP 67 | 68 | PUSH 0x2E60 69 | PUSH 0x0 70 | 71 | RETURN 72 | -------------------------------------------------------------------------------- /contracts/src/asm/fib.easm: -------------------------------------------------------------------------------- 1 | ;; Value of 0 at offset 0 2 | PUSH 0x0 3 | PUSH 0x0 4 | SSTORE 5 | 6 | ;; Value of 1 at offset 1 7 | PUSH 0x1 8 | PUSH 0x1 9 | SSTORE 10 | 11 | ;; Set current fib offset and duplicate it 12 | PUSH 0x2 13 | loop: 14 | DUP1 15 | 16 | 17 | ;; Subtract 1 from the current offset 18 | PUSH 0x1 19 | SWAP1 20 | SUB 21 | DUP1 22 | 23 | ;; Subtract 1 from the current offset (again) 24 | PUSH 0x1 25 | SWAP1 26 | SUB 27 | 28 | ;; Load the two offsets from memory and add them together 29 | SLOAD 30 | SWAP1 31 | SLOAD 32 | ADD 33 | 34 | ;; Store the current offset and latest fib in memory 35 | DUP2 36 | SSTORE 37 | 38 | ;; increment the offset 39 | PUSH 0x1 40 | ADD 41 | 42 | ;; Compare the current offset to 341 43 | DUP1 44 | PUSH 0x155 45 | GT 46 | 47 | PUSH @loop 48 | JUMPI 49 | 50 | ;; we're done... drop the iterator 51 | POP 52 | 53 | 54 | 55 | ;; Push a value on the stack for tracking the number of iterations that we've done 56 | PUSH 0x00 57 | 58 | ;; create a jump dest and label for looping 59 | loop2: 60 | DUP1 61 | 62 | PUSH 0x20 63 | MUL 64 | 65 | DUP2 66 | 67 | SLOAD 68 | 69 | SWAP1 70 | MSTORE 71 | 72 | 73 | ;; increment the counter 74 | PUSH 0x1 75 | ADD 76 | 77 | 78 | DUP1 79 | PUSH 0x155 80 | GT 81 | 82 | ;; push the jump destination for looping 83 | PUSH @loop2 84 | JUMPI 85 | 86 | 87 | PUSH 0x20 88 | MUL 89 | 90 | PUSH 0x0 91 | RETURN 92 | 93 | STOP 94 | -------------------------------------------------------------------------------- /contracts/src/asm/noop-loop.easm: -------------------------------------------------------------------------------- 1 | ;; Push a value on the stack for tracking the number of iterations that we've done 2 | PUSH 0x00 3 | 4 | ;; create a jump dest and label for looping 5 | loop: 6 | 7 | ;; increment the counter 8 | PUSH 0x1 9 | ADD 10 | 11 | 12 | ;; Leave 4096 Gas 13 | PUSH 0x1000 14 | 15 | ;; Get the remaining amount of GAS 16 | GAS 17 | GT 18 | 19 | ;; push the jump destination for looping 20 | PUSH @loop 21 | JUMPI 22 | 23 | ;; drop the iterator 24 | POP 25 | 26 | STOP 27 | 28 | 29 | -------------------------------------------------------------------------------- /contracts/src/asm/sstore-loop.easm: -------------------------------------------------------------------------------- 1 | ;; Push a value on the stack for tracking the number of iterations that we've done 2 | PUSH 0x00 3 | 4 | ;; create a jump dest and label for looping 5 | loop: 6 | 7 | ;; increment the counter 8 | PUSH 0x1 9 | ADD 10 | 11 | 12 | ;; Put the current counter into memory. This will bloat things up nicely 13 | DUP1 14 | DUP1 15 | SSTORE 16 | 17 | ;; SSTORE is very expensive so we need to make sure we have enough 18 | PUSH 0x8000 19 | 20 | ;; Get the remaining amount of GAS 21 | GAS 22 | GT 23 | 24 | ;; push the jump destination for looping 25 | PUSH @loop 26 | JUMPI 27 | 28 | ;; drop the iterator 29 | POP 30 | 31 | STOP 32 | 33 | 34 | -------------------------------------------------------------------------------- /contracts/src/funder/Funder.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | pragma solidity ^0.8.23; 3 | 4 | /// @title Funder 5 | /// @notice A simple smart contract for funding multiple wallets at once. 6 | /// @dev You can use this contract to fund individual wallets or a list of wallets. 7 | /// @dev This contract accepts direct Ether transfers. 8 | contract Funder { 9 | /// @notice The amount to be sent to each account. 10 | uint256 public amount; 11 | 12 | /// @dev Initialize the contract with the specified funding amount. 13 | /// @param _amount The amount to be sent to each account. 14 | constructor(uint256 _amount) { 15 | require(_amount > 0, "The funding amount should be greater than zero"); 16 | amount = _amount; 17 | } 18 | 19 | /// @notice Fund a specific account with the predefined funding amount. 20 | /// @param _address The address of the wallet to be funded. 21 | function fund(address _address) public { 22 | require(_address != address(0), "The funded address should be different than the zero address"); 23 | require(address(this).balance >= amount, "Insufficient contract balance for funding"); 24 | 25 | (bool success, ) = _address.call{value: amount}(""); 26 | require(success, "Funding failed"); 27 | } 28 | 29 | /// @notice Fund multiple wallets with the predefined funding amount. 30 | /// @param _addresses The addresses of the wallets to be funded. 31 | function bulkFund(address[] calldata _addresses) external { 32 | require(address(this).balance >= amount * _addresses.length, "Insufficient contract balance for batch funding"); 33 | for (uint256 i = 0; i < _addresses.length; i++) { 34 | fund(_addresses[i]); 35 | } 36 | } 37 | 38 | /// @notice Allows the contract to accept direct Ether transfers. 39 | receive() external payable {} 40 | } 41 | -------------------------------------------------------------------------------- /contracts/src/tester/ConformanceTester.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | pragma solidity ^0.8.23; 3 | 4 | contract ConformanceTester { 5 | string public name; 6 | mapping(address => uint) public balances; 7 | string public constant RevertErrorMessage = "Test Revert Error Message"; 8 | 9 | constructor(string memory _name) { 10 | name = _name; 11 | } 12 | 13 | function deposit(uint amount) external { 14 | balances[msg.sender] += amount; 15 | } 16 | 17 | function testRevert() public pure{ 18 | revert(RevertErrorMessage); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /contracts/src/tokens/ERC20.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | pragma solidity ^0.8.23; 3 | 4 | import {ERC20 as OZ_ERC20} from "@openzeppelin/token/ERC20/ERC20.sol" ; 5 | 6 | contract ERC20 is OZ_ERC20 { 7 | constructor() OZ_ERC20("MyToken", "MTK") { 8 | _mint(msg.sender, 1000000 * (10 ** uint256(decimals()))); 9 | } 10 | 11 | function mint(uint256 amount) external { 12 | _mint(msg.sender, amount); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /contracts/src/tokens/ERC721.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | pragma solidity ^0.8.23; 3 | 4 | import {ERC721 as OZ_ERC721} from "@openzeppelin/token/ERC721/ERC721.sol"; 5 | 6 | contract ERC721 is OZ_ERC721 { 7 | uint256 public currentTokenId = 0; 8 | 9 | constructor() OZ_ERC721("MyNFT", "MNFT") { 10 | } 11 | 12 | function mintBatch(address to, uint256 amount) public { 13 | for (uint256 i = 0; i < amount; i++) { 14 | uint256 newTokenId = ++currentTokenId; 15 | _safeMint(to, newTokenId); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /doc/assets/monitor.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0xPolygon/polygon-cli/edb6d4b320582f7a06aee54210a8aa93dec430ee/doc/assets/monitor.gif -------------------------------------------------------------------------------- /doc/grafana_panoptichain_dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0xPolygon/polygon-cli/edb6d4b320582f7a06aee54210a8aa93dec430ee/doc/grafana_panoptichain_dashboard.png -------------------------------------------------------------------------------- /doc/polycli_abi_decode.md: -------------------------------------------------------------------------------- 1 | # `polycli abi decode` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Parse an ABI and print the encoded signatures. 15 | 16 | ```bash 17 | polycli abi decode Contract.abi [flags] 18 | ``` 19 | 20 | ## Flags 21 | 22 | ```bash 23 | --data string Provide input data to be unpacked based on the ABI definition 24 | --file string Provide a filename to read and analyze 25 | -h, --help help for decode 26 | ``` 27 | 28 | The command also inherits flags from parent commands. 29 | 30 | ```bash 31 | --config string config file (default is $HOME/.polygon-cli.yaml) 32 | --pretty-logs Should logs be in pretty format or JSON (default true) 33 | -v, --verbosity int 0 - Silent 34 | 100 Panic 35 | 200 Fatal 36 | 300 Error 37 | 400 Warning 38 | 500 Info 39 | 600 Debug 40 | 700 Trace (default 500) 41 | ``` 42 | 43 | ## See also 44 | 45 | - [polycli abi](polycli_abi.md) - Provides encoding and decoding functionalities with contract signatures and ABI. 46 | -------------------------------------------------------------------------------- /doc/polycli_abi_encode.md: -------------------------------------------------------------------------------- 1 | # `polycli abi encode` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | ABI encodes a function signature and the inputs 15 | 16 | ```bash 17 | polycli abi encode [function signature] [args...] [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | [function-signature] is required and is a fragment in the form (). If the function signature has parameters, then those values would have to be passed as arguments after the function signature. 23 | ## Flags 24 | 25 | ```bash 26 | -h, --help help for encode 27 | ``` 28 | 29 | The command also inherits flags from parent commands. 30 | 31 | ```bash 32 | --config string config file (default is $HOME/.polygon-cli.yaml) 33 | --pretty-logs Should logs be in pretty format or JSON (default true) 34 | -v, --verbosity int 0 - Silent 35 | 100 Panic 36 | 200 Fatal 37 | 300 Error 38 | 400 Warning 39 | 500 Info 40 | 600 Debug 41 | 700 Trace (default 500) 42 | ``` 43 | 44 | ## See also 45 | 46 | - [polycli abi](polycli_abi.md) - Provides encoding and decoding functionalities with contract signatures and ABI. 47 | -------------------------------------------------------------------------------- /doc/polycli_cdk.md: -------------------------------------------------------------------------------- 1 | # `polycli cdk` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Utilities for interacting with CDK networks 15 | 16 | ## Usage 17 | 18 | Basic utility commands for interacting with the cdk contracts 19 | ## Flags 20 | 21 | ```bash 22 | --fork-id string The ForkID of the cdk networks (default "12") 23 | -h, --help help for cdk 24 | --rollup-manager-address string The address of the rollup contract 25 | --rpc-url string The RPC URL of the network containing the CDK contracts (default "http://localhost:8545") 26 | ``` 27 | 28 | The command also inherits flags from parent commands. 29 | 30 | ```bash 31 | --config string config file (default is $HOME/.polygon-cli.yaml) 32 | --pretty-logs Should logs be in pretty format or JSON (default true) 33 | -v, --verbosity int 0 - Silent 34 | 100 Panic 35 | 200 Fatal 36 | 300 Error 37 | 400 Warning 38 | 500 Info 39 | 600 Debug 40 | 700 Trace (default 500) 41 | ``` 42 | 43 | ## See also 44 | 45 | - [polycli](polycli.md) - A Swiss Army knife of blockchain tools. 46 | - [polycli cdk bridge](polycli_cdk_bridge.md) - Utilities for interacting with CDK bridge contract 47 | 48 | - [polycli cdk ger](polycli_cdk_ger.md) - Utilities for interacting with CDK global exit root manager contract 49 | 50 | - [polycli cdk rollup](polycli_cdk_rollup.md) - Utilities for interacting with CDK rollup manager to get rollup specific information 51 | 52 | - [polycli cdk rollup-manager](polycli_cdk_rollup-manager.md) - Utilities for interacting with CDK rollup manager contract 53 | 54 | -------------------------------------------------------------------------------- /doc/polycli_cdk_bridge.md: -------------------------------------------------------------------------------- 1 | # `polycli cdk bridge` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Utilities for interacting with CDK bridge contract 15 | 16 | ## Flags 17 | 18 | ```bash 19 | --bridge-address string The address of the bridge contract 20 | -h, --help help for bridge 21 | ``` 22 | 23 | The command also inherits flags from parent commands. 24 | 25 | ```bash 26 | --config string config file (default is $HOME/.polygon-cli.yaml) 27 | --fork-id string The ForkID of the cdk networks (default "12") 28 | --pretty-logs Should logs be in pretty format or JSON (default true) 29 | --rollup-manager-address string The address of the rollup contract 30 | --rpc-url string The RPC URL of the network containing the CDK contracts (default "http://localhost:8545") 31 | -v, --verbosity int 0 - Silent 32 | 100 Panic 33 | 200 Fatal 34 | 300 Error 35 | 400 Warning 36 | 500 Info 37 | 600 Debug 38 | 700 Trace (default 500) 39 | ``` 40 | 41 | ## See also 42 | 43 | - [polycli cdk](polycli_cdk.md) - Utilities for interacting with CDK networks 44 | - [polycli cdk bridge dump](polycli_cdk_bridge_dump.md) - List detailed information about the bridge 45 | 46 | - [polycli cdk bridge inspect](polycli_cdk_bridge_inspect.md) - List some basic information about the bridge 47 | 48 | - [polycli cdk bridge monitor](polycli_cdk_bridge_monitor.md) - Watch for bridge events and display them on the fly 49 | 50 | -------------------------------------------------------------------------------- /doc/polycli_cdk_bridge_dump.md: -------------------------------------------------------------------------------- 1 | # `polycli cdk bridge dump` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | List detailed information about the bridge 15 | 16 | ```bash 17 | polycli cdk bridge dump [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | This command will reach the bridge contract and retrieve detailed information. 23 | 24 | Below is an example of how to use it 25 | 26 | ```bash 27 | polycli cdk bridge dump 28 | --rpc-url https://sepolia.drpc.org 29 | --rollup-manager-address bali 30 | ``` 31 | 32 | ## Flags 33 | 34 | ```bash 35 | -h, --help help for dump 36 | ``` 37 | 38 | The command also inherits flags from parent commands. 39 | 40 | ```bash 41 | --bridge-address string The address of the bridge contract 42 | --config string config file (default is $HOME/.polygon-cli.yaml) 43 | --fork-id string The ForkID of the cdk networks (default "12") 44 | --pretty-logs Should logs be in pretty format or JSON (default true) 45 | --rollup-manager-address string The address of the rollup contract 46 | --rpc-url string The RPC URL of the network containing the CDK contracts (default "http://localhost:8545") 47 | -v, --verbosity int 0 - Silent 48 | 100 Panic 49 | 200 Fatal 50 | 300 Error 51 | 400 Warning 52 | 500 Info 53 | 600 Debug 54 | 700 Trace (default 500) 55 | ``` 56 | 57 | ## See also 58 | 59 | - [polycli cdk bridge](polycli_cdk_bridge.md) - Utilities for interacting with CDK bridge contract 60 | -------------------------------------------------------------------------------- /doc/polycli_cdk_bridge_inspect.md: -------------------------------------------------------------------------------- 1 | # `polycli cdk bridge inspect` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | List some basic information about the bridge 15 | 16 | ```bash 17 | polycli cdk bridge inspect [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | This command will reach the bridge contract and retrieve basic information. 23 | 24 | Below is an example of how to use it 25 | 26 | ```bash 27 | polycli cdk bridge inspect 28 | --rpc-url https://sepolia.drpc.org 29 | --rollup-manager-address bali 30 | ``` 31 | 32 | ## Flags 33 | 34 | ```bash 35 | -h, --help help for inspect 36 | ``` 37 | 38 | The command also inherits flags from parent commands. 39 | 40 | ```bash 41 | --bridge-address string The address of the bridge contract 42 | --config string config file (default is $HOME/.polygon-cli.yaml) 43 | --fork-id string The ForkID of the cdk networks (default "12") 44 | --pretty-logs Should logs be in pretty format or JSON (default true) 45 | --rollup-manager-address string The address of the rollup contract 46 | --rpc-url string The RPC URL of the network containing the CDK contracts (default "http://localhost:8545") 47 | -v, --verbosity int 0 - Silent 48 | 100 Panic 49 | 200 Fatal 50 | 300 Error 51 | 400 Warning 52 | 500 Info 53 | 600 Debug 54 | 700 Trace (default 500) 55 | ``` 56 | 57 | ## See also 58 | 59 | - [polycli cdk bridge](polycli_cdk_bridge.md) - Utilities for interacting with CDK bridge contract 60 | -------------------------------------------------------------------------------- /doc/polycli_cdk_bridge_monitor.md: -------------------------------------------------------------------------------- 1 | # `polycli cdk bridge monitor` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Watch for bridge events and display them on the fly 15 | 16 | ```bash 17 | polycli cdk bridge monitor [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | This command will keep watching for bridge events on chain and print them on the fly. 23 | 24 | Below are some example of how to use it 25 | 26 | ```bash 27 | polycli cdk bridge monitor 28 | --rpc-url https://sepolia.drpc.org 29 | --rollup-manager-address bali 30 | ``` 31 | 32 | ## Flags 33 | 34 | ```bash 35 | -h, --help help for monitor 36 | ``` 37 | 38 | The command also inherits flags from parent commands. 39 | 40 | ```bash 41 | --bridge-address string The address of the bridge contract 42 | --config string config file (default is $HOME/.polygon-cli.yaml) 43 | --fork-id string The ForkID of the cdk networks (default "12") 44 | --pretty-logs Should logs be in pretty format or JSON (default true) 45 | --rollup-manager-address string The address of the rollup contract 46 | --rpc-url string The RPC URL of the network containing the CDK contracts (default "http://localhost:8545") 47 | -v, --verbosity int 0 - Silent 48 | 100 Panic 49 | 200 Fatal 50 | 300 Error 51 | 400 Warning 52 | 500 Info 53 | 600 Debug 54 | 700 Trace (default 500) 55 | ``` 56 | 57 | ## See also 58 | 59 | - [polycli cdk bridge](polycli_cdk_bridge.md) - Utilities for interacting with CDK bridge contract 60 | -------------------------------------------------------------------------------- /doc/polycli_cdk_ger.md: -------------------------------------------------------------------------------- 1 | # `polycli cdk ger` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Utilities for interacting with CDK global exit root manager contract 15 | 16 | ## Flags 17 | 18 | ```bash 19 | --ger-address string The address of the GER contract 20 | -h, --help help for ger 21 | ``` 22 | 23 | The command also inherits flags from parent commands. 24 | 25 | ```bash 26 | --config string config file (default is $HOME/.polygon-cli.yaml) 27 | --fork-id string The ForkID of the cdk networks (default "12") 28 | --pretty-logs Should logs be in pretty format or JSON (default true) 29 | --rollup-manager-address string The address of the rollup contract 30 | --rpc-url string The RPC URL of the network containing the CDK contracts (default "http://localhost:8545") 31 | -v, --verbosity int 0 - Silent 32 | 100 Panic 33 | 200 Fatal 34 | 300 Error 35 | 400 Warning 36 | 500 Info 37 | 600 Debug 38 | 700 Trace (default 500) 39 | ``` 40 | 41 | ## See also 42 | 43 | - [polycli cdk](polycli_cdk.md) - Utilities for interacting with CDK networks 44 | - [polycli cdk ger dump](polycli_cdk_ger_dump.md) - List detailed information about the global exit root manager 45 | 46 | - [polycli cdk ger inspect](polycli_cdk_ger_inspect.md) - List some basic information about the global exit root manager 47 | 48 | - [polycli cdk ger monitor](polycli_cdk_ger_monitor.md) - Watch for global exit root manager events and display them on the fly 49 | 50 | -------------------------------------------------------------------------------- /doc/polycli_cdk_ger_dump.md: -------------------------------------------------------------------------------- 1 | # `polycli cdk ger dump` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | List detailed information about the global exit root manager 15 | 16 | ```bash 17 | polycli cdk ger dump [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | This command will reach the global exit root contract and retrieve detailed information. 23 | 24 | Below is an example of how to use it 25 | 26 | ```bash 27 | polycli cdk ger dump 28 | --rpc-url https://sepolia.drpc.org 29 | --rollup-manager-address bali 30 | ``` 31 | 32 | ## Flags 33 | 34 | ```bash 35 | -h, --help help for dump 36 | ``` 37 | 38 | The command also inherits flags from parent commands. 39 | 40 | ```bash 41 | --config string config file (default is $HOME/.polygon-cli.yaml) 42 | --fork-id string The ForkID of the cdk networks (default "12") 43 | --ger-address string The address of the GER contract 44 | --pretty-logs Should logs be in pretty format or JSON (default true) 45 | --rollup-manager-address string The address of the rollup contract 46 | --rpc-url string The RPC URL of the network containing the CDK contracts (default "http://localhost:8545") 47 | -v, --verbosity int 0 - Silent 48 | 100 Panic 49 | 200 Fatal 50 | 300 Error 51 | 400 Warning 52 | 500 Info 53 | 600 Debug 54 | 700 Trace (default 500) 55 | ``` 56 | 57 | ## See also 58 | 59 | - [polycli cdk ger](polycli_cdk_ger.md) - Utilities for interacting with CDK global exit root manager contract 60 | -------------------------------------------------------------------------------- /doc/polycli_cdk_ger_inspect.md: -------------------------------------------------------------------------------- 1 | # `polycli cdk ger inspect` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | List some basic information about the global exit root manager 15 | 16 | ```bash 17 | polycli cdk ger inspect [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | This command will reach the global exit root contract and retrieve basic information. 23 | 24 | Below is an example of how to use it 25 | 26 | ```bash 27 | polycli cdk ger inspect 28 | --rpc-url https://sepolia.drpc.org 29 | --rollup-manager-address bali 30 | ``` 31 | 32 | ## Flags 33 | 34 | ```bash 35 | -h, --help help for inspect 36 | ``` 37 | 38 | The command also inherits flags from parent commands. 39 | 40 | ```bash 41 | --config string config file (default is $HOME/.polygon-cli.yaml) 42 | --fork-id string The ForkID of the cdk networks (default "12") 43 | --ger-address string The address of the GER contract 44 | --pretty-logs Should logs be in pretty format or JSON (default true) 45 | --rollup-manager-address string The address of the rollup contract 46 | --rpc-url string The RPC URL of the network containing the CDK contracts (default "http://localhost:8545") 47 | -v, --verbosity int 0 - Silent 48 | 100 Panic 49 | 200 Fatal 50 | 300 Error 51 | 400 Warning 52 | 500 Info 53 | 600 Debug 54 | 700 Trace (default 500) 55 | ``` 56 | 57 | ## See also 58 | 59 | - [polycli cdk ger](polycli_cdk_ger.md) - Utilities for interacting with CDK global exit root manager contract 60 | -------------------------------------------------------------------------------- /doc/polycli_cdk_ger_monitor.md: -------------------------------------------------------------------------------- 1 | # `polycli cdk ger monitor` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Watch for global exit root manager events and display them on the fly 15 | 16 | ```bash 17 | polycli cdk ger monitor [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | This command will keep watching for global exit root events on chain and print them on the fly. 23 | 24 | Below are some example of how to use it 25 | 26 | ```bash 27 | polycli cdk ger monitor 28 | --rpc-url https://sepolia.drpc.org 29 | --rollup-manager-address bali 30 | ``` 31 | 32 | ## Flags 33 | 34 | ```bash 35 | -h, --help help for monitor 36 | ``` 37 | 38 | The command also inherits flags from parent commands. 39 | 40 | ```bash 41 | --config string config file (default is $HOME/.polygon-cli.yaml) 42 | --fork-id string The ForkID of the cdk networks (default "12") 43 | --ger-address string The address of the GER contract 44 | --pretty-logs Should logs be in pretty format or JSON (default true) 45 | --rollup-manager-address string The address of the rollup contract 46 | --rpc-url string The RPC URL of the network containing the CDK contracts (default "http://localhost:8545") 47 | -v, --verbosity int 0 - Silent 48 | 100 Panic 49 | 200 Fatal 50 | 300 Error 51 | 400 Warning 52 | 500 Info 53 | 600 Debug 54 | 700 Trace (default 500) 55 | ``` 56 | 57 | ## See also 58 | 59 | - [polycli cdk ger](polycli_cdk_ger.md) - Utilities for interacting with CDK global exit root manager contract 60 | -------------------------------------------------------------------------------- /doc/polycli_cdk_rollup-manager.md: -------------------------------------------------------------------------------- 1 | # `polycli cdk rollup-manager` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Utilities for interacting with CDK rollup manager contract 15 | 16 | ## Flags 17 | 18 | ```bash 19 | -h, --help help for rollup-manager 20 | ``` 21 | 22 | The command also inherits flags from parent commands. 23 | 24 | ```bash 25 | --config string config file (default is $HOME/.polygon-cli.yaml) 26 | --fork-id string The ForkID of the cdk networks (default "12") 27 | --pretty-logs Should logs be in pretty format or JSON (default true) 28 | --rollup-manager-address string The address of the rollup contract 29 | --rpc-url string The RPC URL of the network containing the CDK contracts (default "http://localhost:8545") 30 | -v, --verbosity int 0 - Silent 31 | 100 Panic 32 | 200 Fatal 33 | 300 Error 34 | 400 Warning 35 | 500 Info 36 | 600 Debug 37 | 700 Trace (default 500) 38 | ``` 39 | 40 | ## See also 41 | 42 | - [polycli cdk](polycli_cdk.md) - Utilities for interacting with CDK networks 43 | - [polycli cdk rollup-manager dump](polycli_cdk_rollup-manager_dump.md) - List detailed information about the rollup manager 44 | 45 | - [polycli cdk rollup-manager inspect](polycli_cdk_rollup-manager_inspect.md) - List some basic information about the rollup manager 46 | 47 | - [polycli cdk rollup-manager list-rollup-types](polycli_cdk_rollup-manager_list-rollup-types.md) - List some basic information about each rollup type 48 | 49 | - [polycli cdk rollup-manager list-rollups](polycli_cdk_rollup-manager_list-rollups.md) - List some basic information about each rollup 50 | 51 | - [polycli cdk rollup-manager monitor](polycli_cdk_rollup-manager_monitor.md) - Watch for rollup manager events and display them on the fly 52 | 53 | -------------------------------------------------------------------------------- /doc/polycli_cdk_rollup-manager_dump.md: -------------------------------------------------------------------------------- 1 | # `polycli cdk rollup-manager dump` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | List detailed information about the rollup manager 15 | 16 | ```bash 17 | polycli cdk rollup-manager dump [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | This command will reach the rollup manager contract and retrieve detailed information. 23 | 24 | Below is an example of how to use it 25 | 26 | ```bash 27 | polycli cdk rollup-manager dump 28 | --rpc-url https://sepolia.drpc.org 29 | --rollup-manager-address bali 30 | ``` 31 | 32 | ## Flags 33 | 34 | ```bash 35 | -h, --help help for dump 36 | ``` 37 | 38 | The command also inherits flags from parent commands. 39 | 40 | ```bash 41 | --config string config file (default is $HOME/.polygon-cli.yaml) 42 | --fork-id string The ForkID of the cdk networks (default "12") 43 | --pretty-logs Should logs be in pretty format or JSON (default true) 44 | --rollup-manager-address string The address of the rollup contract 45 | --rpc-url string The RPC URL of the network containing the CDK contracts (default "http://localhost:8545") 46 | -v, --verbosity int 0 - Silent 47 | 100 Panic 48 | 200 Fatal 49 | 300 Error 50 | 400 Warning 51 | 500 Info 52 | 600 Debug 53 | 700 Trace (default 500) 54 | ``` 55 | 56 | ## See also 57 | 58 | - [polycli cdk rollup-manager](polycli_cdk_rollup-manager.md) - Utilities for interacting with CDK rollup manager contract 59 | -------------------------------------------------------------------------------- /doc/polycli_cdk_rollup-manager_inspect.md: -------------------------------------------------------------------------------- 1 | # `polycli cdk rollup-manager inspect` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | List some basic information about the rollup manager 15 | 16 | ```bash 17 | polycli cdk rollup-manager inspect [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | This command will reach the rollup manager contract and retrieve basic information. 23 | 24 | Below is an example of how to use it 25 | 26 | ```bash 27 | polycli cdk rollup-manager inspect 28 | --rpc-url https://sepolia.drpc.org 29 | --rollup-manager-address bali 30 | ``` 31 | 32 | ## Flags 33 | 34 | ```bash 35 | -h, --help help for inspect 36 | ``` 37 | 38 | The command also inherits flags from parent commands. 39 | 40 | ```bash 41 | --config string config file (default is $HOME/.polygon-cli.yaml) 42 | --fork-id string The ForkID of the cdk networks (default "12") 43 | --pretty-logs Should logs be in pretty format or JSON (default true) 44 | --rollup-manager-address string The address of the rollup contract 45 | --rpc-url string The RPC URL of the network containing the CDK contracts (default "http://localhost:8545") 46 | -v, --verbosity int 0 - Silent 47 | 100 Panic 48 | 200 Fatal 49 | 300 Error 50 | 400 Warning 51 | 500 Info 52 | 600 Debug 53 | 700 Trace (default 500) 54 | ``` 55 | 56 | ## See also 57 | 58 | - [polycli cdk rollup-manager](polycli_cdk_rollup-manager.md) - Utilities for interacting with CDK rollup manager contract 59 | -------------------------------------------------------------------------------- /doc/polycli_cdk_rollup-manager_list-rollup-types.md: -------------------------------------------------------------------------------- 1 | # `polycli cdk rollup-manager list-rollup-types` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | List some basic information about each rollup type 15 | 16 | ```bash 17 | polycli cdk rollup-manager list-rollup-types [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | This command will reach the rollup manager contract and retrieve all information about the rollups types registered. 23 | 24 | Below is an example of how to use it 25 | 26 | ```bash 27 | polycli cdk rollup-manager list-rollup-types 28 | --rpc-url https://sepolia.drpc.org 29 | --rollup-manager-address bali 30 | ``` 31 | 32 | ## Flags 33 | 34 | ```bash 35 | -h, --help help for list-rollup-types 36 | ``` 37 | 38 | The command also inherits flags from parent commands. 39 | 40 | ```bash 41 | --config string config file (default is $HOME/.polygon-cli.yaml) 42 | --fork-id string The ForkID of the cdk networks (default "12") 43 | --pretty-logs Should logs be in pretty format or JSON (default true) 44 | --rollup-manager-address string The address of the rollup contract 45 | --rpc-url string The RPC URL of the network containing the CDK contracts (default "http://localhost:8545") 46 | -v, --verbosity int 0 - Silent 47 | 100 Panic 48 | 200 Fatal 49 | 300 Error 50 | 400 Warning 51 | 500 Info 52 | 600 Debug 53 | 700 Trace (default 500) 54 | ``` 55 | 56 | ## See also 57 | 58 | - [polycli cdk rollup-manager](polycli_cdk_rollup-manager.md) - Utilities for interacting with CDK rollup manager contract 59 | -------------------------------------------------------------------------------- /doc/polycli_cdk_rollup-manager_list-rollups.md: -------------------------------------------------------------------------------- 1 | # `polycli cdk rollup-manager list-rollups` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | List some basic information about each rollup 15 | 16 | ```bash 17 | polycli cdk rollup-manager list-rollups [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | This command will reach the rollup manager contract and retrieve all information about the rollups registered. 23 | 24 | Below is an example of how to use it 25 | 26 | ```bash 27 | polycli cdk rollup-manager list-rollups 28 | --rpc-url https://sepolia.drpc.org 29 | --rollup-manager-address bali 30 | ``` 31 | 32 | ## Flags 33 | 34 | ```bash 35 | -h, --help help for list-rollups 36 | ``` 37 | 38 | The command also inherits flags from parent commands. 39 | 40 | ```bash 41 | --config string config file (default is $HOME/.polygon-cli.yaml) 42 | --fork-id string The ForkID of the cdk networks (default "12") 43 | --pretty-logs Should logs be in pretty format or JSON (default true) 44 | --rollup-manager-address string The address of the rollup contract 45 | --rpc-url string The RPC URL of the network containing the CDK contracts (default "http://localhost:8545") 46 | -v, --verbosity int 0 - Silent 47 | 100 Panic 48 | 200 Fatal 49 | 300 Error 50 | 400 Warning 51 | 500 Info 52 | 600 Debug 53 | 700 Trace (default 500) 54 | ``` 55 | 56 | ## See also 57 | 58 | - [polycli cdk rollup-manager](polycli_cdk_rollup-manager.md) - Utilities for interacting with CDK rollup manager contract 59 | -------------------------------------------------------------------------------- /doc/polycli_cdk_rollup-manager_monitor.md: -------------------------------------------------------------------------------- 1 | # `polycli cdk rollup-manager monitor` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Watch for rollup manager events and display them on the fly 15 | 16 | ```bash 17 | polycli cdk rollup-manager monitor [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | This command will keep watching for rollup manager events on chain and print them on the fly. 23 | 24 | Below is an example of how to use it 25 | 26 | ```bash 27 | polycli cdk rollup-manager monitor 28 | --rpc-url https://sepolia.drpc.org 29 | --rollup-manager-address bali 30 | ``` 31 | 32 | ## Flags 33 | 34 | ```bash 35 | -h, --help help for monitor 36 | ``` 37 | 38 | The command also inherits flags from parent commands. 39 | 40 | ```bash 41 | --config string config file (default is $HOME/.polygon-cli.yaml) 42 | --fork-id string The ForkID of the cdk networks (default "12") 43 | --pretty-logs Should logs be in pretty format or JSON (default true) 44 | --rollup-manager-address string The address of the rollup contract 45 | --rpc-url string The RPC URL of the network containing the CDK contracts (default "http://localhost:8545") 46 | -v, --verbosity int 0 - Silent 47 | 100 Panic 48 | 200 Fatal 49 | 300 Error 50 | 400 Warning 51 | 500 Info 52 | 600 Debug 53 | 700 Trace (default 500) 54 | ``` 55 | 56 | ## See also 57 | 58 | - [polycli cdk rollup-manager](polycli_cdk_rollup-manager.md) - Utilities for interacting with CDK rollup manager contract 59 | -------------------------------------------------------------------------------- /doc/polycli_cdk_rollup.md: -------------------------------------------------------------------------------- 1 | # `polycli cdk rollup` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Utilities for interacting with CDK rollup manager to get rollup specific information 15 | 16 | ## Flags 17 | 18 | ```bash 19 | -h, --help help for rollup 20 | --rollup-address string The rollup Address 21 | --rollup-chain-id string The rollup chain ID 22 | --rollup-id string The rollup ID 23 | ``` 24 | 25 | The command also inherits flags from parent commands. 26 | 27 | ```bash 28 | --config string config file (default is $HOME/.polygon-cli.yaml) 29 | --fork-id string The ForkID of the cdk networks (default "12") 30 | --pretty-logs Should logs be in pretty format or JSON (default true) 31 | --rollup-manager-address string The address of the rollup contract 32 | --rpc-url string The RPC URL of the network containing the CDK contracts (default "http://localhost:8545") 33 | -v, --verbosity int 0 - Silent 34 | 100 Panic 35 | 200 Fatal 36 | 300 Error 37 | 400 Warning 38 | 500 Info 39 | 600 Debug 40 | 700 Trace (default 500) 41 | ``` 42 | 43 | ## See also 44 | 45 | - [polycli cdk](polycli_cdk.md) - Utilities for interacting with CDK networks 46 | - [polycli cdk rollup dump](polycli_cdk_rollup_dump.md) - List detailed information about a specific rollup 47 | 48 | - [polycli cdk rollup inspect](polycli_cdk_rollup_inspect.md) - List some basic information about a specific rollup 49 | 50 | - [polycli cdk rollup monitor](polycli_cdk_rollup_monitor.md) - Watch for rollup events and display them on the fly 51 | 52 | -------------------------------------------------------------------------------- /doc/polycli_cdk_rollup_dump.md: -------------------------------------------------------------------------------- 1 | # `polycli cdk rollup dump` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | List detailed information about a specific rollup 15 | 16 | ```bash 17 | polycli cdk rollup dump [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | This command will reach the rollup manager contract and retrieve detailed information from a specific rollup. 23 | 24 | Below is an example of how to use it 25 | 26 | ```bash 27 | polycli cdk rollup dump 28 | --rpc-url https://sepolia.drpc.org 29 | --rollup-manager-address bali 30 | --rollup-id 1 31 | 32 | polycli cdk rollup dump 33 | --rpc-url https://sepolia.drpc.org 34 | --rollup-manager-address bali 35 | --rollup-chain-id 2440 36 | 37 | polycli cdk rollup dump 38 | --rpc-url https://sepolia.drpc.org 39 | --rollup-manager-address bali 40 | --rollup-address 0x89ba0ed947a88fe43c22ae305c0713ec8a7eb361 41 | ``` 42 | 43 | ## Flags 44 | 45 | ```bash 46 | -h, --help help for dump 47 | ``` 48 | 49 | The command also inherits flags from parent commands. 50 | 51 | ```bash 52 | --config string config file (default is $HOME/.polygon-cli.yaml) 53 | --fork-id string The ForkID of the cdk networks (default "12") 54 | --pretty-logs Should logs be in pretty format or JSON (default true) 55 | --rollup-address string The rollup Address 56 | --rollup-chain-id string The rollup chain ID 57 | --rollup-id string The rollup ID 58 | --rollup-manager-address string The address of the rollup contract 59 | --rpc-url string The RPC URL of the network containing the CDK contracts (default "http://localhost:8545") 60 | -v, --verbosity int 0 - Silent 61 | 100 Panic 62 | 200 Fatal 63 | 300 Error 64 | 400 Warning 65 | 500 Info 66 | 600 Debug 67 | 700 Trace (default 500) 68 | ``` 69 | 70 | ## See also 71 | 72 | - [polycli cdk rollup](polycli_cdk_rollup.md) - Utilities for interacting with CDK rollup manager to get rollup specific information 73 | -------------------------------------------------------------------------------- /doc/polycli_cdk_rollup_inspect.md: -------------------------------------------------------------------------------- 1 | # `polycli cdk rollup inspect` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | List some basic information about a specific rollup 15 | 16 | ```bash 17 | polycli cdk rollup inspect [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | This command will reach the rollup manager contract and retrieve basic information from a specific rollup. 23 | 24 | Below is an example of how to use it 25 | 26 | ```bash 27 | polycli cdk rollup inspect 28 | --rpc-url https://sepolia.drpc.org 29 | --rollup-manager-address bali 30 | --rollup-id 1 31 | 32 | polycli cdk rollup inspect 33 | --rpc-url https://sepolia.drpc.org 34 | --rollup-manager-address bali 35 | --rollup-chain-id 2440 36 | 37 | polycli cdk rollup inspect 38 | --rpc-url https://sepolia.drpc.org 39 | --rollup-manager-address bali 40 | --rollup-address 0x89ba0ed947a88fe43c22ae305c0713ec8a7eb361 41 | ``` 42 | 43 | ## Flags 44 | 45 | ```bash 46 | -h, --help help for inspect 47 | ``` 48 | 49 | The command also inherits flags from parent commands. 50 | 51 | ```bash 52 | --config string config file (default is $HOME/.polygon-cli.yaml) 53 | --fork-id string The ForkID of the cdk networks (default "12") 54 | --pretty-logs Should logs be in pretty format or JSON (default true) 55 | --rollup-address string The rollup Address 56 | --rollup-chain-id string The rollup chain ID 57 | --rollup-id string The rollup ID 58 | --rollup-manager-address string The address of the rollup contract 59 | --rpc-url string The RPC URL of the network containing the CDK contracts (default "http://localhost:8545") 60 | -v, --verbosity int 0 - Silent 61 | 100 Panic 62 | 200 Fatal 63 | 300 Error 64 | 400 Warning 65 | 500 Info 66 | 600 Debug 67 | 700 Trace (default 500) 68 | ``` 69 | 70 | ## See also 71 | 72 | - [polycli cdk rollup](polycli_cdk_rollup.md) - Utilities for interacting with CDK rollup manager to get rollup specific information 73 | -------------------------------------------------------------------------------- /doc/polycli_cdk_rollup_monitor.md: -------------------------------------------------------------------------------- 1 | # `polycli cdk rollup monitor` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Watch for rollup events and display them on the fly 15 | 16 | ```bash 17 | polycli cdk rollup monitor [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | This command will keep watching for rollup manager events from a specific rollup on chain and print them on the fly. 23 | 24 | Below are some example of how to use it 25 | 26 | ```bash 27 | polycli cdk rollup monitor 28 | --rpc-url https://sepolia.drpc.org 29 | --rollup-manager-address bali 30 | --rollup-id 1 31 | 32 | polycli cdk rollup monitor 33 | --rpc-url https://sepolia.drpc.org 34 | --rollup-manager-address bali 35 | --rollup-chain-id 2440 36 | 37 | polycli cdk rollup monitor 38 | --rpc-url https://sepolia.drpc.org 39 | --rollup-manager-address bali 40 | --rollup-address 0x89ba0ed947a88fe43c22ae305c0713ec8a7eb361 41 | ``` 42 | 43 | ## Flags 44 | 45 | ```bash 46 | -h, --help help for monitor 47 | ``` 48 | 49 | The command also inherits flags from parent commands. 50 | 51 | ```bash 52 | --config string config file (default is $HOME/.polygon-cli.yaml) 53 | --fork-id string The ForkID of the cdk networks (default "12") 54 | --pretty-logs Should logs be in pretty format or JSON (default true) 55 | --rollup-address string The rollup Address 56 | --rollup-chain-id string The rollup chain ID 57 | --rollup-id string The rollup ID 58 | --rollup-manager-address string The address of the rollup contract 59 | --rpc-url string The RPC URL of the network containing the CDK contracts (default "http://localhost:8545") 60 | -v, --verbosity int 0 - Silent 61 | 100 Panic 62 | 200 Fatal 63 | 300 Error 64 | 400 Warning 65 | 500 Info 66 | 600 Debug 67 | 700 Trace (default 500) 68 | ``` 69 | 70 | ## See also 71 | 72 | - [polycli cdk rollup](polycli_cdk_rollup.md) - Utilities for interacting with CDK rollup manager to get rollup specific information 73 | -------------------------------------------------------------------------------- /doc/polycli_ecrecover.md: -------------------------------------------------------------------------------- 1 | # `polycli ecrecover` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Recovers and returns the public key of the signature 15 | 16 | ```bash 17 | polycli ecrecover [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | Recover public key from block 23 | 24 | ```bash 25 | polycli ecrecover -r https://polygon-mumbai-bor.publicnode.com -b 45200775 26 | > Recovering signer from block #45200775 27 | > 0x5082F249cDb2f2c1eE035E4f423c46EA2daB3ab1 28 | 29 | polycli ecrecover -r https://polygon-rpc.com 30 | > Recovering signer from block #52888893 31 | > 0xeEDBa2484aAF940f37cd3CD21a5D7C4A7DAfbfC0 32 | 33 | polycli ecrecover -f block-52888893.json 34 | > Recovering signer from block #52888893 35 | > 0xeEDBa2484aAF940f37cd3CD21a5D7C4A7DAfbfC0 36 | 37 | cat block-52888893.json | go run main.go ecrecover 38 | > Recovering signer from block #52888893 39 | > 0xeEDBa2484aAF940f37cd3CD21a5D7C4A7DAfbfC0 40 | ``` 41 | 42 | JSON Data passed in follows object definition [here](https://www.quicknode.com/docs/ethereum/eth_getBlockByNumber) 43 | 44 | ## Flags 45 | 46 | ```bash 47 | -b, --block-number uint Block number to check the extra data for (default: latest) 48 | -f, --file string Path to a file containing block information in JSON format 49 | -h, --help help for ecrecover 50 | -r, --rpc-url string The RPC endpoint url 51 | -t, --tx string Transaction data in hex format 52 | ``` 53 | 54 | The command also inherits flags from parent commands. 55 | 56 | ```bash 57 | --config string config file (default is $HOME/.polygon-cli.yaml) 58 | --pretty-logs Should logs be in pretty format or JSON (default true) 59 | -v, --verbosity int 0 - Silent 60 | 100 Panic 61 | 200 Fatal 62 | 300 Error 63 | 400 Warning 64 | 500 Info 65 | 600 Debug 66 | 700 Trace (default 500) 67 | ``` 68 | 69 | ## See also 70 | 71 | - [polycli](polycli.md) - A Swiss Army knife of blockchain tools. 72 | -------------------------------------------------------------------------------- /doc/polycli_fold-trace.md: -------------------------------------------------------------------------------- 1 | # `polycli fold-trace` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Trace an execution trace and fold it for visualization 15 | 16 | ```bash 17 | polycli fold-trace [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | This command is meant to take a transaction op code trace and convert it into a folded output that can be easily visualized with Flamegraph tools. 23 | 24 | ```bash 25 | # First grab a trace from an RPC that supports the debug namespace 26 | cast rpc --rpc-url http://127.0.0.1:18545 debug_traceTransaction 0x12f63f489213f5bd5b88fbfb12960b8248f61e2062a369ba41d8a3c96bb74d57 > trace.json 27 | 28 | # Read the trace and use the `fold-trace` command and write the output 29 | polycli fold-trace --metric actualgas < trace.json > folded-trace.out 30 | 31 | # Convert the folded trace into a flame graph 32 | flamegraph.pl --title "Gas Profile for 0x7405fc5e254352350bebcadc1392bd06f158aa88e9fb01733389621a29db5f08" --width 1920 --countname folded-trace.out > flame.svg 33 | ``` 34 | ## Flags 35 | 36 | ```bash 37 | --file string Provide a filename to read and hash 38 | -h, --help help for fold-trace 39 | --metric string Provide a metric name for analysis: gas, count, actualgas (default "gas") 40 | --root-context string The name for the top most initial context (default "root context") 41 | ``` 42 | 43 | The command also inherits flags from parent commands. 44 | 45 | ```bash 46 | --config string config file (default is $HOME/.polygon-cli.yaml) 47 | --pretty-logs Should logs be in pretty format or JSON (default true) 48 | -v, --verbosity int 0 - Silent 49 | 100 Panic 50 | 200 Fatal 51 | 300 Error 52 | 400 Warning 53 | 500 Info 54 | 600 Debug 55 | 700 Trace (default 500) 56 | ``` 57 | 58 | ## See also 59 | 60 | - [polycli](polycli.md) - A Swiss Army knife of blockchain tools. 61 | -------------------------------------------------------------------------------- /doc/polycli_fork.md: -------------------------------------------------------------------------------- 1 | # `polycli fork` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Take a forked block and walk up the chain to do analysis. 15 | 16 | ```bash 17 | polycli fork blockhash url [flags] 18 | ``` 19 | 20 | ## Flags 21 | 22 | ```bash 23 | -h, --help help for fork 24 | ``` 25 | 26 | The command also inherits flags from parent commands. 27 | 28 | ```bash 29 | --config string config file (default is $HOME/.polygon-cli.yaml) 30 | --pretty-logs Should logs be in pretty format or JSON (default true) 31 | -v, --verbosity int 0 - Silent 32 | 100 Panic 33 | 200 Fatal 34 | 300 Error 35 | 400 Warning 36 | 500 Info 37 | 600 Debug 38 | 700 Trace (default 500) 39 | ``` 40 | 41 | ## See also 42 | 43 | - [polycli](polycli.md) - A Swiss Army knife of blockchain tools. 44 | -------------------------------------------------------------------------------- /doc/polycli_hash.md: -------------------------------------------------------------------------------- 1 | # `polycli hash` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Provide common crypto hashing functions. 15 | 16 | ```bash 17 | polycli hash [md4|md5|sha1|sha224|sha256|sha384|sha512|ripemd160|sha3_224|sha3_256|sha3_384|sha3_512|sha512_224|sha512_256|blake2s_256|blake2b_256|blake2b_384|blake2b_512|keccak256|keccak512|poseidon|poseidongold] [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | ```bash 23 | $ echo -n "hello" > hello.txt 24 | $ polycli hash sha1 --file hello.txt 25 | aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d 26 | $ echo -n "hello" | polycli hash sha1 27 | aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d 28 | $ polycli hash sha1 hello 29 | aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d 30 | ``` 31 | 32 | ## Flags 33 | 34 | ```bash 35 | --file string Provide a filename to read and hash 36 | -h, --help help for hash 37 | ``` 38 | 39 | The command also inherits flags from parent commands. 40 | 41 | ```bash 42 | --config string config file (default is $HOME/.polygon-cli.yaml) 43 | --pretty-logs Should logs be in pretty format or JSON (default true) 44 | -v, --verbosity int 0 - Silent 45 | 100 Panic 46 | 200 Fatal 47 | 300 Error 48 | 400 Warning 49 | 500 Info 50 | 600 Debug 51 | 700 Trace (default 500) 52 | ``` 53 | 54 | ## See also 55 | 56 | - [polycli](polycli.md) - A Swiss Army knife of blockchain tools. 57 | -------------------------------------------------------------------------------- /doc/polycli_mnemonic.md: -------------------------------------------------------------------------------- 1 | # `polycli mnemonic` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Generate a BIP39 mnemonic seed. 15 | 16 | ```bash 17 | polycli mnemonic [flags] 18 | ``` 19 | 20 | ## Flags 21 | 22 | ```bash 23 | -h, --help help for mnemonic 24 | --language string Which language to use [ChineseSimplified, ChineseTraditional, Czech, English, French, Italian, Japanese, Korean, Spanish] (default "english") 25 | --words int The number of words to use in the mnemonic (default 24) 26 | ``` 27 | 28 | The command also inherits flags from parent commands. 29 | 30 | ```bash 31 | --config string config file (default is $HOME/.polygon-cli.yaml) 32 | --pretty-logs Should logs be in pretty format or JSON (default true) 33 | -v, --verbosity int 0 - Silent 34 | 100 Panic 35 | 200 Fatal 36 | 300 Error 37 | 400 Warning 38 | 500 Info 39 | 600 Debug 40 | 700 Trace (default 500) 41 | ``` 42 | 43 | ## See also 44 | 45 | - [polycli](polycli.md) - A Swiss Army knife of blockchain tools. 46 | -------------------------------------------------------------------------------- /doc/polycli_monitor.md: -------------------------------------------------------------------------------- 1 | # `polycli monitor` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Monitor blocks using a JSON-RPC endpoint. 15 | 16 | ```bash 17 | polycli monitor [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | ![GIF of `polycli monitor`](assets/monitor.gif) 23 | 24 | If you're using the terminal UI and you'd like to be able to select text for copying, you might need to use a modifier key. 25 | 26 | If you're experiencing missing blocks, try adjusting the `--batch-size` and `--interval` flags so that you poll for more blocks or more frequently. 27 | 28 | ## Flags 29 | 30 | ```bash 31 | -b, --batch-size string Number of requests per batch (default "auto") 32 | -c, --cache-limit int Number of cached blocks for the LRU block data structure (Min 100) (default 200) 33 | -h, --help help for monitor 34 | -i, --interval string Amount of time between batch block rpc calls (default "5s") 35 | -r, --rpc-url string The RPC endpoint url (default "http://localhost:8545") 36 | -s, --sub-batch-size int Number of requests per sub-batch (default 50) 37 | ``` 38 | 39 | The command also inherits flags from parent commands. 40 | 41 | ```bash 42 | --config string config file (default is $HOME/.polygon-cli.yaml) 43 | --pretty-logs Should logs be in pretty format or JSON (default true) 44 | -v, --verbosity int 0 - Silent 45 | 100 Panic 46 | 200 Fatal 47 | 300 Error 48 | 400 Warning 49 | 500 Info 50 | 600 Debug 51 | 700 Trace (default 500) 52 | ``` 53 | 54 | ## See also 55 | 56 | - [polycli](polycli.md) - A Swiss Army knife of blockchain tools. 57 | -------------------------------------------------------------------------------- /doc/polycli_monitor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0xPolygon/polygon-cli/edb6d4b320582f7a06aee54210a8aa93dec430ee/doc/polycli_monitor.png -------------------------------------------------------------------------------- /doc/polycli_p2p_crawl.md: -------------------------------------------------------------------------------- 1 | # `polycli p2p crawl` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Crawl a network on the devp2p layer and generate a nodes JSON file. 15 | 16 | ```bash 17 | polycli p2p crawl [nodes file] [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | If no nodes.json file exists, it will be created. 23 | ## Flags 24 | 25 | ```bash 26 | -b, --bootnodes string Comma separated nodes used for bootstrapping. At least one bootnode is 27 | required, so other nodes in the network can discover each other. 28 | -d, --database string Node database for updating and storing client information 29 | --discovery-dns string Enable EIP-1459, DNS Discovery to recover node list from given ENRTree 30 | -h, --help help for crawl 31 | -n, --network-id uint Filter discovered nodes by this network id 32 | -u, --only-urls Only writes the enode URLs to the output (default true) 33 | -p, --parallel int How many parallel discoveries to attempt (default 16) 34 | -r, --revalidation-interval string Time before retrying to connect to a failed peer (default "10m") 35 | -t, --timeout string Time limit for the crawl (default "30m0s") 36 | ``` 37 | 38 | The command also inherits flags from parent commands. 39 | 40 | ```bash 41 | --config string config file (default is $HOME/.polygon-cli.yaml) 42 | --pretty-logs Should logs be in pretty format or JSON (default true) 43 | -v, --verbosity int 0 - Silent 44 | 100 Panic 45 | 200 Fatal 46 | 300 Error 47 | 400 Warning 48 | 500 Info 49 | 600 Debug 50 | 700 Trace (default 500) 51 | ``` 52 | 53 | ## See also 54 | 55 | - [polycli p2p](polycli_p2p.md) - Set of commands related to devp2p. 56 | -------------------------------------------------------------------------------- /doc/polycli_p2p_nodelist.md: -------------------------------------------------------------------------------- 1 | # `polycli p2p nodelist` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Generate a node list to seed a node 15 | 16 | ```bash 17 | polycli p2p nodelist [nodes.json] [flags] 18 | ``` 19 | 20 | ## Flags 21 | 22 | ```bash 23 | -h, --help help for nodelist 24 | -l, --limit int Number of unique nodes to return (default 100) 25 | -p, --project-id string GCP project ID 26 | ``` 27 | 28 | The command also inherits flags from parent commands. 29 | 30 | ```bash 31 | --config string config file (default is $HOME/.polygon-cli.yaml) 32 | --pretty-logs Should logs be in pretty format or JSON (default true) 33 | -v, --verbosity int 0 - Silent 34 | 100 Panic 35 | 200 Fatal 36 | 300 Error 37 | 400 Warning 38 | 500 Info 39 | 600 Debug 40 | 700 Trace (default 500) 41 | ``` 42 | 43 | ## See also 44 | 45 | - [polycli p2p](polycli_p2p.md) - Set of commands related to devp2p. 46 | -------------------------------------------------------------------------------- /doc/polycli_p2p_ping.md: -------------------------------------------------------------------------------- 1 | # `polycli p2p ping` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Ping node(s) and return the output. 15 | 16 | ```bash 17 | polycli p2p ping [enode/enr or nodes file] [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | Ping nodes by either giving a single enode/enr or an entire nodes file. 23 | 24 | This command will establish a handshake and status exchange to get the Hello and 25 | Status messages and output JSON. If providing a enode/enr rather than a nodes 26 | file, then the connection will remain open by default (--listen=true), and you 27 | can see other messages the peer sends (e.g. blocks, transactions, etc.). 28 | ## Flags 29 | 30 | ```bash 31 | -h, --help help for ping 32 | -l, --listen Keep the connection open and listen to the peer. This only works if the first 33 | argument is an enode/enr, not a nodes file. (default true) 34 | -o, --output string Write ping results to output file (default stdout) 35 | -p, --parallel int How many parallel pings to attempt (default 16) 36 | ``` 37 | 38 | The command also inherits flags from parent commands. 39 | 40 | ```bash 41 | --config string config file (default is $HOME/.polygon-cli.yaml) 42 | --pretty-logs Should logs be in pretty format or JSON (default true) 43 | -v, --verbosity int 0 - Silent 44 | 100 Panic 45 | 200 Fatal 46 | 300 Error 47 | 400 Warning 48 | 500 Info 49 | 600 Debug 50 | 700 Trace (default 500) 51 | ``` 52 | 53 | ## See also 54 | 55 | - [polycli p2p](polycli_p2p.md) - Set of commands related to devp2p. 56 | -------------------------------------------------------------------------------- /doc/polycli_p2p_query.md: -------------------------------------------------------------------------------- 1 | # `polycli p2p query` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Query block header(s) from node and prints the output. 15 | 16 | ```bash 17 | polycli p2p query [enode/enr] [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | Query header of single block or range of blocks given a single enode/enr. 23 | 24 | This command will initially establish a handshake and exchange status message 25 | from the peer. Then, it will query the node for block(s) given the start block 26 | and the amount of blocks to query and print the results. 27 | ## Flags 28 | 29 | ```bash 30 | -a, --amount uint Amount of blocks to query (default 1) 31 | -h, --help help for query 32 | -s, --start-block uint Block number to start querying from 33 | ``` 34 | 35 | The command also inherits flags from parent commands. 36 | 37 | ```bash 38 | --config string config file (default is $HOME/.polygon-cli.yaml) 39 | --pretty-logs Should logs be in pretty format or JSON (default true) 40 | -v, --verbosity int 0 - Silent 41 | 100 Panic 42 | 200 Fatal 43 | 300 Error 44 | 400 Warning 45 | 500 Info 46 | 600 Debug 47 | 700 Trace (default 500) 48 | ``` 49 | 50 | ## See also 51 | 52 | - [polycli p2p](polycli_p2p.md) - Set of commands related to devp2p. 53 | -------------------------------------------------------------------------------- /doc/polycli_ulxly_compute-nullifier-tree.md: -------------------------------------------------------------------------------- 1 | # `polycli ulxly compute-nullifier-tree` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Compute the nullifier tree given the claims 15 | 16 | ```bash 17 | polycli ulxly compute-nullifier-tree [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | This command will attempt to computethe nullifierTree based on the claims that are provided. 23 | 24 | Example usage: 25 | 26 | ```bash 27 | polycli ulxly compute-nullifier-tree \ 28 | --file-name claims-cardona-4880876-to-6028159.ndjson | jq '.' 29 | ``` 30 | 31 | In this case we are assuming we have a file 32 | `claims-cardona-4880876-to-6028159.ndjson` that would have been generated 33 | with a call to `polycli ulxly get-claims`. The output will be the 34 | claims necessary to compute the nullifier tree. 35 | 36 | This is the response from polycli: 37 | 38 | ```json 39 | { 40 | "root": "0x4516ca2a793b8e20f56ec6ba8ca6033a672330670a3772f76f2ade9bc2125150"", 41 | } 42 | ``` 43 | 44 | Note: more info https://github.com/BrianSeong99/Agglayer_PessimisticProof_Benchmark?tab=readme-ov-file#architecture-of-pessimistic-proof 45 | ## Flags 46 | 47 | ```bash 48 | --file-name string An ndjson file with events data 49 | -h, --help help for compute-nullifier-tree 50 | ``` 51 | 52 | The command also inherits flags from parent commands. 53 | 54 | ```bash 55 | --config string config file (default is $HOME/.polygon-cli.yaml) 56 | --pretty-logs Should logs be in pretty format or JSON (default true) 57 | -v, --verbosity int 0 - Silent 58 | 100 Panic 59 | 200 Fatal 60 | 300 Error 61 | 400 Warning 62 | 500 Info 63 | 600 Debug 64 | 700 Trace (default 500) 65 | ``` 66 | 67 | ## See also 68 | 69 | - [polycli ulxly](polycli_ulxly.md) - Utilities for interacting with the uLxLy bridge 70 | -------------------------------------------------------------------------------- /doc/polycli_ulxly_empty-proof.md: -------------------------------------------------------------------------------- 1 | # `polycli ulxly empty-proof` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | create an empty proof 15 | 16 | ```bash 17 | polycli ulxly empty-proof [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | Use this command to print an empty proof response that's filled with zero-valued siblings like 0x0000000000000000000000000000000000000000000000000000000000000000. This can be useful when you need to submit a dummy proof. 23 | ## Flags 24 | 25 | ```bash 26 | -h, --help help for empty-proof 27 | ``` 28 | 29 | The command also inherits flags from parent commands. 30 | 31 | ```bash 32 | --config string config file (default is $HOME/.polygon-cli.yaml) 33 | --pretty-logs Should logs be in pretty format or JSON (default true) 34 | -v, --verbosity int 0 - Silent 35 | 100 Panic 36 | 200 Fatal 37 | 300 Error 38 | 400 Warning 39 | 500 Info 40 | 600 Debug 41 | 700 Trace (default 500) 42 | ``` 43 | 44 | ## See also 45 | 46 | - [polycli ulxly](polycli_ulxly.md) - Utilities for interacting with the uLxLy bridge 47 | -------------------------------------------------------------------------------- /doc/polycli_ulxly_zero-proof.md: -------------------------------------------------------------------------------- 1 | # `polycli ulxly zero-proof` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | create a proof that's filled with zeros 15 | 16 | ```bash 17 | polycli ulxly zero-proof [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | Use this command to print a proof response that's filled with the zero 23 | hashes. This values are very helpful for debugging because it would 24 | tell you how populated the tree is and roughly which leaves and 25 | siblings are empty. It's also helpful for sanity checking a proof 26 | response to understand if the hashed value is part of the zero hashes 27 | or if it's actually an intermediate hash. 28 | ## Flags 29 | 30 | ```bash 31 | -h, --help help for zero-proof 32 | ``` 33 | 34 | The command also inherits flags from parent commands. 35 | 36 | ```bash 37 | --config string config file (default is $HOME/.polygon-cli.yaml) 38 | --pretty-logs Should logs be in pretty format or JSON (default true) 39 | -v, --verbosity int 0 - Silent 40 | 100 Panic 41 | 200 Fatal 42 | 300 Error 43 | 400 Warning 44 | 500 Info 45 | 600 Debug 46 | 700 Trace (default 500) 47 | ``` 48 | 49 | ## See also 50 | 51 | - [polycli ulxly](polycli_ulxly.md) - Utilities for interacting with the uLxLy bridge 52 | -------------------------------------------------------------------------------- /doc/polycli_version.md: -------------------------------------------------------------------------------- 1 | # `polycli version` 2 | 3 | > Auto-generated documentation. 4 | 5 | ## Table of Contents 6 | 7 | - [Description](#description) 8 | - [Usage](#usage) 9 | - [Flags](#flags) 10 | - [See Also](#see-also) 11 | 12 | ## Description 13 | 14 | Get the current version of this application 15 | 16 | ```bash 17 | polycli version [flags] 18 | ``` 19 | 20 | ## Usage 21 | 22 | Nothing fancy. Print the version of this application 23 | ## Flags 24 | 25 | ```bash 26 | -h, --help help for version 27 | ``` 28 | 29 | The command also inherits flags from parent commands. 30 | 31 | ```bash 32 | --config string config file (default is $HOME/.polygon-cli.yaml) 33 | --pretty-logs Should logs be in pretty format or JSON (default true) 34 | -v, --verbosity int 0 - Silent 35 | 100 Panic 36 | 200 Fatal 37 | 300 Error 38 | 400 Warning 39 | 500 Info 40 | 600 Debug 41 | 700 Trace (default 500) 42 | ``` 43 | 44 | ## See also 45 | 46 | - [polycli](polycli.md) - A Swiss Army knife of blockchain tools. 47 | -------------------------------------------------------------------------------- /docker/Dockerfile.gen-doc: -------------------------------------------------------------------------------- 1 | FROM --platform=$BUILDPLATFORM golang:1.23-bookworm 2 | 3 | WORKDIR /gen 4 | 5 | CMD go run docutil/*.go 6 | -------------------------------------------------------------------------------- /docker/Dockerfile.gen-go-bindings: -------------------------------------------------------------------------------- 1 | FROM --platform=$BUILDPLATFORM golang:1.23-bookworm 2 | 3 | WORKDIR /gen 4 | 5 | RUN apt-get update 6 | 7 | # the user/group info may mismatch between container and host, and it 8 | # may cause git to complain with `detected dubious ownership in repository`. 9 | RUN git config --global --add safe.directory /gen 10 | 11 | ## Install abigen 12 | RUN go install github.com/ethereum/go-ethereum/cmd/abigen@latest 13 | RUN abigen --version 14 | 15 | ## Install foundry 16 | RUN curl -L https://foundry.paradigm.xyz | bash 17 | RUN . ~/.bashrc 18 | ENV PATH="/root/.foundry/bin:${PATH}" 19 | RUN ~/.foundry/bin/foundryup 20 | RUN ~/.foundry/bin/forge --version 21 | 22 | ## Install jq 23 | RUN apt-get install -y jq 24 | 25 | WORKDIR /gen/contracts 26 | 27 | CMD forge install && make gen-go-bindings 28 | -------------------------------------------------------------------------------- /docker/Dockerfile.gen-json-rpc-types: -------------------------------------------------------------------------------- 1 | FROM --platform=$BUILDPLATFORM golang:1.23-bookworm 2 | 3 | WORKDIR /gen 4 | 5 | RUN apt-get update 6 | 7 | ## Install nodejs and npm 8 | RUN apt-get install -y nodejs npm 9 | 10 | ## Install jq 11 | RUN apt-get install -y jq 12 | 13 | CMD ./scripts/rpctypes.sh rpctypes/jsonschemas/ 14 | -------------------------------------------------------------------------------- /docker/Dockerfile.gen-load-test-modes: -------------------------------------------------------------------------------- 1 | FROM --platform=$BUILDPLATFORM golang:1.23-bookworm 2 | 3 | WORKDIR /gen 4 | 5 | # https://pkg.go.dev/golang.org/x/tools/cmd/stringer?tab=versions 6 | ARG STRINGER_VERSION="0.31.0" 7 | 8 | ## Install stringer 9 | RUN go install golang.org/x/tools/cmd/stringer@v${STRINGER_VERSION} 10 | 11 | WORKDIR /gen/cmd/loadtest 12 | 13 | CMD stringer -type=loadTestMode 14 | -------------------------------------------------------------------------------- /docker/Dockerfile.gen-proto: -------------------------------------------------------------------------------- 1 | FROM --platform=$BUILDPLATFORM golang:1.23-bookworm 2 | 3 | WORKDIR /gen 4 | 5 | RUN apt-get update 6 | 7 | ARG ARCH="linux-x86_64" 8 | # https://github.com/protocolbuffers/protobuf/releases 9 | ARG PROTOC_VERSION="29.3" 10 | # https://pkg.go.dev/google.golang.org/protobuf/cmd/protoc-gen-go?tab=versions 11 | ARG PROTOC_GEN_GO_VERSION="1.36.5" 12 | # https://pkg.go.dev/google.golang.org/grpc/cmd/protoc-gen-go-grpc?tab=versions 13 | ARG PROTOC_GEN_GO_GRPC_VERSION="1.5.1" 14 | 15 | # Core Dependencies 16 | RUN apt-get install -y unzip 17 | 18 | # Dependencies to generate protobuf stubs. 19 | ## Install protoc 20 | RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${ARCH}.zip 21 | RUN unzip protoc-${PROTOC_VERSION}-${ARCH}.zip 22 | RUN rm protoc-${PROTOC_VERSION}-${ARCH}.zip 23 | RUN rm readme.txt 24 | RUN mv bin/protoc /usr/local/bin/ 25 | RUN mv include/google /usr/local/include 26 | RUN protoc --version 27 | 28 | ## Install protoc plugins for go 29 | RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v${PROTOC_GEN_GO_VERSION} 30 | RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v${PROTOC_GEN_GO_GRPC_VERSION} 31 | RUN protoc-gen-go --version 32 | RUN protoc-gen-go-grpc --version 33 | 34 | CMD protoc --proto_path=proto --go_out=proto/gen/pb --go_opt=paths=source_relative $(find ./proto -iname "*.proto") 35 | -------------------------------------------------------------------------------- /docutil/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | 7 | "github.com/0xPolygon/polygon-cli/cmd" 8 | ) 9 | 10 | var ( 11 | // Directory in which the documentation will be generated. 12 | docDir = "doc" 13 | 14 | // Tag used to delimitate the section of the README which is generated. 15 | delimiter = "generated" 16 | ) 17 | 18 | func main() { 19 | polycli := cmd.NewPolycliCommand() 20 | 21 | // Generate documentation for the `polycli` command. 22 | if err := genMarkdownDoc(polycli, docDir); err != nil { 23 | fmt.Println("Unable to generate documentation.") 24 | log.Fatal(err) 25 | } 26 | fmt.Println("Documentation generated!") 27 | 28 | // Update the summary of commands in the `README.md` (located inside ) 29 | if err := updateReadmeCommands(polycli, delimiter, docDir); err != nil { 30 | fmt.Println("Unable to update `README.md`.") 31 | log.Fatal(err) 32 | } 33 | fmt.Println("`README.md` updated!") 34 | } 35 | -------------------------------------------------------------------------------- /docutil/readme.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "os" 7 | "strings" 8 | 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // updateReadmeCommands will update the list of `polycli` commands. 13 | // The section is identified by the HTML tags `“. 14 | func updateReadmeCommands(cmd *cobra.Command, delimiter, docDir string) error { 15 | // Generate the list of commands. 16 | buf := new(bytes.Buffer) 17 | name := cmd.CommandPath() 18 | addDocPrefix := func(s string) string { return fmt.Sprintf("%s/%s", docDir, s) } 19 | printSeeAlso(buf, cmd, name, addDocPrefix) 20 | 21 | // Update the `README.md`` 22 | data, err := os.ReadFile("README.md") 23 | if err != nil { 24 | return err 25 | } 26 | var newData string 27 | newData, err = updateContent(string(data), delimiter, buf) 28 | if err != nil { 29 | return err 30 | } 31 | err = os.WriteFile("README.md", []byte(newData), 0644) 32 | if err != nil { 33 | return err 34 | } 35 | return nil 36 | } 37 | 38 | // Take a piece of data and update the content between the start and end tags with new content. 39 | func updateContent(originalContent, delimiter string, newContent *bytes.Buffer) (string, error) { 40 | startTag := fmt.Sprintf("<%s>", delimiter) 41 | endTag := fmt.Sprintf("", delimiter) 42 | startIndex := strings.Index(originalContent, startTag) 43 | endIndex := strings.Index(originalContent, endTag) 44 | if startIndex == -1 || endIndex == -1 || endIndex <= startIndex { 45 | return "", fmt.Errorf("Unable to find start and end tags or they are in the wrong order.") 46 | } 47 | startIndex += len(startTag) 48 | return originalContent[:startIndex] + "\n" + newContent.String() + originalContent[endIndex:], nil 49 | } 50 | -------------------------------------------------------------------------------- /gethkeystore/gethkeystore.go: -------------------------------------------------------------------------------- 1 | package gethkeystore 2 | 3 | import ( 4 | "crypto/ecdsa" 5 | 6 | "encoding/hex" 7 | "encoding/json" 8 | "github.com/ethereum/go-ethereum/accounts/keystore" 9 | "github.com/ethereum/go-ethereum/crypto" 10 | ) 11 | 12 | type RawKeystoreData struct { 13 | Address string `json:"address"` 14 | Crypto keystore.CryptoJSON `json:"crypto"` 15 | } 16 | 17 | func DecryptKeystoreFile(fileData []byte, password string) (*ecdsa.PrivateKey, error) { 18 | var encryptedData RawKeystoreData 19 | err := json.Unmarshal(fileData, &encryptedData) 20 | if err != nil { 21 | return nil, err 22 | } 23 | decryptedData, err := keystore.DecryptDataV3(encryptedData.Crypto, password) 24 | if err != nil { 25 | return nil, err 26 | } 27 | 28 | privKeyStr := hex.EncodeToString(decryptedData) 29 | 30 | privKey, err := crypto.HexToECDSA(privKeyStr) 31 | if err != nil { 32 | return nil, err 33 | } 34 | return privKey, nil 35 | } 36 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/0xPolygon/polygon-cli/cmd" 4 | 5 | func main() { 6 | cmd.Execute() 7 | } 8 | -------------------------------------------------------------------------------- /p2p/database/database.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | import ( 4 | "context" 5 | "math/big" 6 | "time" 7 | 8 | "github.com/ethereum/go-ethereum/common" 9 | "github.com/ethereum/go-ethereum/core/types" 10 | "github.com/ethereum/go-ethereum/eth/protocols/eth" 11 | "github.com/ethereum/go-ethereum/p2p" 12 | "github.com/ethereum/go-ethereum/p2p/enode" 13 | ) 14 | 15 | // Database represents a database solution to write block and transaction data 16 | // to. To use another database solution, just implement these methods and 17 | // update the sensor to use the new connection. 18 | type Database interface { 19 | // WriteBlock will write the both the block and block event to the database 20 | // if ShouldWriteBlocks and ShouldWriteBlockEvents return true, respectively. 21 | WriteBlock(context.Context, *enode.Node, *types.Block, *big.Int, time.Time) 22 | 23 | // WriteBlockHeaders will write the block headers if ShouldWriteBlocks 24 | // returns true. 25 | WriteBlockHeaders(context.Context, []*types.Header, time.Time) 26 | 27 | // WriteBlockHashes will write the block hashes if ShouldWriteBlockEvents 28 | // returns true. 29 | WriteBlockHashes(context.Context, *enode.Node, []common.Hash, time.Time) 30 | 31 | // WriteBlockBody will write the block bodies if ShouldWriteBlocks returns 32 | // true. 33 | WriteBlockBody(context.Context, *eth.BlockBody, common.Hash, time.Time) 34 | 35 | // WriteTransactions will write the both the transaction and transaction 36 | // event to the database if ShouldWriteTransactions and 37 | // ShouldWriteTransactionEvents return true, respectively. 38 | WriteTransactions(context.Context, *enode.Node, []*types.Transaction, time.Time) 39 | 40 | // WritePeers will write the connected peers to the database. 41 | WritePeers(context.Context, []*p2p.Peer, time.Time) 42 | 43 | // HasBlock will return whether the block is in the database. If the database 44 | // client has not been initialized this will always return true. 45 | HasBlock(context.Context, common.Hash) bool 46 | 47 | MaxConcurrentWrites() int 48 | ShouldWriteBlocks() bool 49 | ShouldWriteBlockEvents() bool 50 | ShouldWriteTransactions() bool 51 | ShouldWriteTransactionEvents() bool 52 | ShouldWritePeers() bool 53 | 54 | // NodeList will return a list of enode URLs. 55 | NodeList(ctx context.Context, limit int) ([]string, error) 56 | } 57 | -------------------------------------------------------------------------------- /packaging/deb/polycli/DEBIAN/README.md: -------------------------------------------------------------------------------- 1 | # Debian 2 | 3 | 4 | 5 | For debian packages you will need to add the following layouts during the build 6 | 7 | 8 | 9 | polycli/ 10 | DEBIAN/control 11 | /usr/bin/polycli 12 | 13 | This will be wrapped during the build package process building 14 | 15 | 16 | Note this is still a work in progress: 17 | 18 | TODO: removal/purge on removal using dpkg 19 | cleanup of control files to list what we want 20 | copyright inclusion 21 | -------------------------------------------------------------------------------- /packaging/templates/package_scripts/control: -------------------------------------------------------------------------------- 1 | Source: polygon-cli 2 | Version: 0.3.5-beta 3 | Section: main 4 | Priority: standard 5 | Maintainer: Polygon 6 | Build-Depends: debhelper-compat (= 13) 7 | Package: polygon-cli 8 | Rules-Requires-Root: yes 9 | Architecture: amd64 10 | Multi-Arch: foreign 11 | Depends: 12 | Description: A Swiss Army knife of blockchain tools (from Polygon Technology). 13 | -------------------------------------------------------------------------------- /proto/block.proto: -------------------------------------------------------------------------------- 1 | // If you make changes, recompile protos with `make generate` 2 | syntax = "proto3"; 3 | package proto; 4 | option go_package = "github.com/0xPolygon/polygon-cli/proto/gen/pb;pb"; 5 | 6 | import "transaction.proto"; 7 | 8 | message Block { 9 | string author = 1; 10 | string difficulty = 2; 11 | string extraData = 3; 12 | string gasLimit = 4; 13 | string gasUsed = 5; 14 | string hash = 6; 15 | string logsBloom = 7; 16 | string miner = 8; 17 | string number = 9; 18 | string parentHash = 10; 19 | string receiptsRoot = 11; 20 | string sha3Uncles = 12; 21 | string signature = 13; 22 | string size = 14; 23 | string stateRoot = 15; 24 | uint32 step = 16; 25 | string totalDifficulty = 17; 26 | string timestamp = 18; 27 | repeated Transaction transactions = 19; 28 | string transactionsRoot = 20; 29 | repeated string uncles = 21; 30 | string baseFeePerGas = 22; 31 | string mixHash = 23; 32 | string nonce = 24; 33 | } 34 | -------------------------------------------------------------------------------- /proto/transaction.proto: -------------------------------------------------------------------------------- 1 | // If you make changes, recompile protos with `make generate` 2 | syntax = "proto3"; 3 | package proto; 4 | option go_package = "github.com/0xPolygon/polygon-cli/proto/gen/pb;pb"; 5 | 6 | message Transaction { 7 | string hash = 1; 8 | string nonce = 2; 9 | string blockHash = 3; 10 | string blockNumber = 4; 11 | string transactionIndex = 5; 12 | string from = 6; 13 | optional string to = 7; 14 | string value = 8; 15 | string gasPrice = 9; 16 | string gas = 10; 17 | string data = 11; 18 | string input = 12; 19 | string type = 13; 20 | string v = 14; 21 | string s = 15; 22 | string r = 16; 23 | } 24 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/README.org: -------------------------------------------------------------------------------- 1 | The openrpc.json file comes from this repo: 2 | https://github.com/ethereum/execution-apis 3 | 4 | In order to build it, we run: 5 | 6 | #+BEGIN_SRC bash 7 | npm install 8 | npm run build 9 | #+END_SRC 10 | 11 | Rather than keeping a unique schema per method, we'll try to decompose 12 | into unique schemas for simplicity. 13 | 14 | #+BEGIN_SRC bash 15 | cat openrpc.json | jq '.methods[].name' | sort 16 | cat openrpc.json | jq '.methods[] | select(.name == "eth_syncing") | .result.schema' 17 | #+END_SRC 18 | 19 | Or you can run the following from project root folder: 20 | 21 | #+BEGIN_SRC bash 22 | make gen-json-rpctypes 23 | #+END_SRC 24 | 25 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/debug_getRawBlock.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "hex encoded bytes", 3 | "type": "string", 4 | "pattern": "^0x[0-9a-f]*$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/debug_getRawHeader.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "hex encoded bytes", 3 | "type": "string", 4 | "pattern": "^0x[0-9a-f]*$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/debug_getRawReceipts.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Receipt array", 3 | "type": "array", 4 | "items": { 5 | "title": "hex encoded bytes", 6 | "type": "string", 7 | "pattern": "^0x[0-9a-f]*$" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/debug_getRawTransaction.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "hex encoded bytes", 3 | "type": "string", 4 | "pattern": "^0x[0-9a-f]*$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/engine_exchangeCapabilities.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "array", 3 | "items": { 4 | "type": "string" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/engine_exchangeTransitionConfigurationV1.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Transition configuration object", 3 | "type": "object", 4 | "required": [ 5 | "terminalTotalDifficulty", 6 | "terminalBlockHash", 7 | "terminalBlockNumber" 8 | ], 9 | "properties": { 10 | "terminalTotalDifficulty": { 11 | "title": "Terminal total difficulty", 12 | "type": "string", 13 | "pattern": "^0x([1-9a-f]+[0-9a-f]{0,31})|0$" 14 | }, 15 | "terminalBlockHash": { 16 | "title": "Terminal block hash", 17 | "type": "string", 18 | "pattern": "^0x[0-9a-f]{64}$" 19 | }, 20 | "terminalBlockNumber": { 21 | "title": "Terminal block number", 22 | "type": "string", 23 | "pattern": "^0x([1-9a-f]+[0-9a-f]{0,15})|0$" 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/engine_forkchoiceUpdatedV1.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Forkchoice updated response", 3 | "type": "object", 4 | "required": [ 5 | "payloadStatus" 6 | ], 7 | "properties": { 8 | "payloadStatus": { 9 | "title": "Payload status", 10 | "type": "object", 11 | "required": [ 12 | "status" 13 | ], 14 | "properties": { 15 | "status": { 16 | "title": "Payload validation status", 17 | "type": "string", 18 | "enum": [ 19 | "VALID", 20 | "INVALID", 21 | "SYNCING" 22 | ], 23 | "description": "Set of possible values is restricted to VALID, INVALID, SYNCING" 24 | }, 25 | "latestValidHash": { 26 | "title": "The hash of the most recent valid block", 27 | "type": "string", 28 | "pattern": "^0x[0-9a-f]{64}$" 29 | }, 30 | "validationError": { 31 | "title": "Validation error message", 32 | "type": "string" 33 | } 34 | } 35 | }, 36 | "payloadId": { 37 | "title": "Payload id", 38 | "type": "string", 39 | "pattern": "^0x[0-9a-f]{16}$" 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/engine_forkchoiceUpdatedV2.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Forkchoice updated response", 3 | "type": "object", 4 | "required": [ 5 | "payloadStatus" 6 | ], 7 | "properties": { 8 | "payloadStatus": { 9 | "title": "Payload status", 10 | "type": "object", 11 | "required": [ 12 | "status" 13 | ], 14 | "properties": { 15 | "status": { 16 | "title": "Payload validation status", 17 | "type": "string", 18 | "enum": [ 19 | "VALID", 20 | "INVALID", 21 | "SYNCING" 22 | ], 23 | "description": "Set of possible values is restricted to VALID, INVALID, SYNCING" 24 | }, 25 | "latestValidHash": { 26 | "title": "The hash of the most recent valid block", 27 | "type": "string", 28 | "pattern": "^0x[0-9a-f]{64}$" 29 | }, 30 | "validationError": { 31 | "title": "Validation error message", 32 | "type": "string" 33 | } 34 | } 35 | }, 36 | "payloadId": { 37 | "title": "Payload id", 38 | "type": "string", 39 | "pattern": "^0x[0-9a-f]{16}$" 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/engine_forkchoiceUpdatedV3.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Forkchoice updated response", 3 | "type": "object", 4 | "required": [ 5 | "payloadStatus" 6 | ], 7 | "properties": { 8 | "payloadStatus": { 9 | "title": "Payload status", 10 | "type": "object", 11 | "required": [ 12 | "status" 13 | ], 14 | "properties": { 15 | "status": { 16 | "title": "Payload validation status", 17 | "type": "string", 18 | "enum": [ 19 | "VALID", 20 | "INVALID", 21 | "SYNCING" 22 | ], 23 | "description": "Set of possible values is restricted to VALID, INVALID, SYNCING" 24 | }, 25 | "latestValidHash": { 26 | "title": "The hash of the most recent valid block", 27 | "type": "string", 28 | "pattern": "^0x[0-9a-f]{64}$" 29 | }, 30 | "validationError": { 31 | "title": "Validation error message", 32 | "type": "string" 33 | } 34 | } 35 | }, 36 | "payloadId": { 37 | "title": "Payload id", 38 | "type": "string", 39 | "pattern": "^0x[0-9a-f]{16}$" 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/engine_getPayloadBodiesByHashV1.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "array", 3 | "items": { 4 | "title": "Execution payload body object V1", 5 | "type": "object", 6 | "required": [ 7 | "transactions" 8 | ], 9 | "properties": { 10 | "transactions": { 11 | "title": "Transactions", 12 | "type": "array", 13 | "items": { 14 | "title": "hex encoded bytes", 15 | "type": "string", 16 | "pattern": "^0x[0-9a-f]*$" 17 | } 18 | }, 19 | "withdrawals": { 20 | "title": "Withdrawals", 21 | "type": [ 22 | "array", 23 | "null" 24 | ], 25 | "items": { 26 | "title": "Withdrawal object V1", 27 | "type": "object", 28 | "required": [ 29 | "index", 30 | "validatorIndex", 31 | "address", 32 | "amount" 33 | ], 34 | "properties": { 35 | "index": { 36 | "title": "Withdrawal index", 37 | "type": "string", 38 | "pattern": "^0x([1-9a-f]+[0-9a-f]{0,15})|0$" 39 | }, 40 | "validatorIndex": { 41 | "title": "Validator index", 42 | "type": "string", 43 | "pattern": "^0x([1-9a-f]+[0-9a-f]{0,15})|0$" 44 | }, 45 | "address": { 46 | "title": "Withdrawal address", 47 | "type": "string", 48 | "pattern": "^0x[0-9,a-f,A-F]{40}$" 49 | }, 50 | "amount": { 51 | "title": "Withdrawal amount", 52 | "type": "string", 53 | "pattern": "^0x([1-9a-f]+[0-9a-f]{0,15})|0$" 54 | } 55 | } 56 | } 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/engine_getPayloadBodiesByRangeV1.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "array", 3 | "items": { 4 | "title": "Execution payload body object V1", 5 | "type": "object", 6 | "required": [ 7 | "transactions" 8 | ], 9 | "properties": { 10 | "transactions": { 11 | "title": "Transactions", 12 | "type": "array", 13 | "items": { 14 | "title": "hex encoded bytes", 15 | "type": "string", 16 | "pattern": "^0x[0-9a-f]*$" 17 | } 18 | }, 19 | "withdrawals": { 20 | "title": "Withdrawals", 21 | "type": [ 22 | "array", 23 | "null" 24 | ], 25 | "items": { 26 | "title": "Withdrawal object V1", 27 | "type": "object", 28 | "required": [ 29 | "index", 30 | "validatorIndex", 31 | "address", 32 | "amount" 33 | ], 34 | "properties": { 35 | "index": { 36 | "title": "Withdrawal index", 37 | "type": "string", 38 | "pattern": "^0x([1-9a-f]+[0-9a-f]{0,15})|0$" 39 | }, 40 | "validatorIndex": { 41 | "title": "Validator index", 42 | "type": "string", 43 | "pattern": "^0x([1-9a-f]+[0-9a-f]{0,15})|0$" 44 | }, 45 | "address": { 46 | "title": "Withdrawal address", 47 | "type": "string", 48 | "pattern": "^0x[0-9,a-f,A-F]{40}$" 49 | }, 50 | "amount": { 51 | "title": "Withdrawal amount", 52 | "type": "string", 53 | "pattern": "^0x([1-9a-f]+[0-9a-f]{0,15})|0$" 54 | } 55 | } 56 | } 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/engine_newPayloadV1.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Payload status object V1", 3 | "type": "object", 4 | "required": [ 5 | "status" 6 | ], 7 | "properties": { 8 | "status": { 9 | "title": "Payload validation status", 10 | "type": "string", 11 | "enum": [ 12 | "VALID", 13 | "INVALID", 14 | "SYNCING", 15 | "ACCEPTED", 16 | "INVALID_BLOCK_HASH" 17 | ] 18 | }, 19 | "latestValidHash": { 20 | "title": "The hash of the most recent valid block", 21 | "type": "string", 22 | "pattern": "^0x[0-9a-f]{64}$" 23 | }, 24 | "validationError": { 25 | "title": "Validation error message", 26 | "type": "string" 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/engine_newPayloadV2.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Payload status object deprecating INVALID_BLOCK_HASH status", 3 | "type": "object", 4 | "required": [ 5 | "status" 6 | ], 7 | "properties": { 8 | "status": { 9 | "title": "Payload validation status", 10 | "type": "string", 11 | "enum": [ 12 | "VALID", 13 | "INVALID", 14 | "SYNCING", 15 | "ACCEPTED" 16 | ] 17 | }, 18 | "latestValidHash": { 19 | "title": "The hash of the most recent valid block", 20 | "type": "string", 21 | "pattern": "^0x[0-9a-f]{64}$" 22 | }, 23 | "validationError": { 24 | "title": "Validation error message", 25 | "type": "string" 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/engine_newPayloadV3.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Payload status object deprecating INVALID_BLOCK_HASH status", 3 | "type": "object", 4 | "required": [ 5 | "status" 6 | ], 7 | "properties": { 8 | "status": { 9 | "title": "Payload validation status", 10 | "type": "string", 11 | "enum": [ 12 | "VALID", 13 | "INVALID", 14 | "SYNCING", 15 | "ACCEPTED" 16 | ] 17 | }, 18 | "latestValidHash": { 19 | "title": "The hash of the most recent valid block", 20 | "type": "string", 21 | "pattern": "^0x[0-9a-f]{64}$" 22 | }, 23 | "validationError": { 24 | "title": "Validation error message", 25 | "type": "string" 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/engine_newPayloadV4.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Payload status object deprecating INVALID_BLOCK_HASH status", 3 | "type": "object", 4 | "required": [ 5 | "status" 6 | ], 7 | "properties": { 8 | "status": { 9 | "title": "Payload validation status", 10 | "type": "string", 11 | "enum": [ 12 | "VALID", 13 | "INVALID", 14 | "SYNCING", 15 | "ACCEPTED" 16 | ] 17 | }, 18 | "latestValidHash": { 19 | "title": "The hash of the most recent valid block", 20 | "type": "string", 21 | "pattern": "^0x[0-9a-f]{64}$" 22 | }, 23 | "validationError": { 24 | "title": "Validation error message", 25 | "type": "string" 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_accounts.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Accounts", 3 | "type": "array", 4 | "items": { 5 | "title": "hex encoded address", 6 | "type": "string", 7 | "pattern": "^0x[0-9,a-f,A-F]{40}$" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_blobBaseFee.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Blob gas base fee", 3 | "type": "string", 4 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_blockNumber.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "hex encoded unsigned integer", 3 | "type": "string", 4 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_call.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "hex encoded bytes", 3 | "type": "string", 4 | "pattern": "^0x[0-9a-f]*$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_chainId.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "hex encoded unsigned integer", 3 | "type": "string", 4 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_coinbase.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "hex encoded address", 3 | "type": "string", 4 | "pattern": "^0x[0-9,a-f,A-F]{40}$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_createAccessList.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Access list result", 3 | "type": "object", 4 | "additionalProperties": false, 5 | "properties": { 6 | "accessList": { 7 | "title": "accessList", 8 | "type": "array", 9 | "items": { 10 | "title": "Access list entry", 11 | "type": "object", 12 | "additionalProperties": false, 13 | "properties": { 14 | "address": { 15 | "title": "hex encoded address", 16 | "type": "string", 17 | "pattern": "^0x[0-9,a-f,A-F]{40}$" 18 | }, 19 | "storageKeys": { 20 | "type": "array", 21 | "items": { 22 | "title": "32 byte hex value", 23 | "type": "string", 24 | "pattern": "^0x[0-9a-f]{64}$" 25 | } 26 | } 27 | } 28 | } 29 | }, 30 | "error": { 31 | "title": "error", 32 | "type": "string" 33 | }, 34 | "gasUsed": { 35 | "title": "Gas used", 36 | "type": "string", 37 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_estimateGas.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "hex encoded unsigned integer", 3 | "type": "string", 4 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_feeHistory.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "feeHistoryResults", 3 | "description": "Fee history results.", 4 | "type": "object", 5 | "required": [ 6 | "oldestBlock", 7 | "baseFeePerGas", 8 | "gasUsedRatio" 9 | ], 10 | "additionalProperties": false, 11 | "properties": { 12 | "oldestBlock": { 13 | "title": "oldestBlock", 14 | "type": "string", 15 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$", 16 | "description": "Lowest number block of returned range." 17 | }, 18 | "baseFeePerGas": { 19 | "title": "baseFeePerGasArray", 20 | "description": "An array of block base fees per gas. This includes the next block after the newest of the returned range, because this value can be derived from the newest block. Zeroes are returned for pre-EIP-1559 blocks.", 21 | "type": "array", 22 | "items": { 23 | "title": "hex encoded unsigned integer", 24 | "type": "string", 25 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 26 | } 27 | }, 28 | "gasUsedRatio": { 29 | "title": "gasUsedRatio", 30 | "description": "An array of block gas used ratios. These are calculated as the ratio of gasUsed and gasLimit.", 31 | "type": "array", 32 | "items": { 33 | "title": "normalized ratio", 34 | "type": "number", 35 | "minimum": 0, 36 | "maximum": 1 37 | } 38 | }, 39 | "reward": { 40 | "title": "rewardArray", 41 | "description": "A two-dimensional array of effective priority fees per gas at the requested block percentiles.", 42 | "type": "array", 43 | "items": { 44 | "title": "rewardPercentile", 45 | "description": "An array of effective priority fee per gas data points from a single block. All zeroes are returned if the block is empty.", 46 | "type": "array", 47 | "items": { 48 | "title": "rewardPercentile", 49 | "type": "string", 50 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$", 51 | "description": "A given percentile sample of effective priority fees per gas from a single block in ascending order, weighted by gas used. Zeroes are returned if the block is empty." 52 | } 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_gasPrice.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Gas price", 3 | "type": "string", 4 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_getBalance.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "hex encoded unsigned integer", 3 | "type": "string", 4 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_getBlockTransactionCountByHash.json: -------------------------------------------------------------------------------- 1 | { 2 | "oneOf": [ 3 | { 4 | "title": "Not Found (null)", 5 | "type": "null" 6 | }, 7 | { 8 | "title": "Transaction count", 9 | "type": "string", 10 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_getBlockTransactionCountByNumber.json: -------------------------------------------------------------------------------- 1 | { 2 | "oneOf": [ 3 | { 4 | "title": "Not Found (null)", 5 | "type": "null" 6 | }, 7 | { 8 | "title": "Transaction count", 9 | "type": "string", 10 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_getCode.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "hex encoded bytes", 3 | "type": "string", 4 | "pattern": "^0x[0-9a-f]*$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_getFilterChanges.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Filter results", 3 | "oneOf": [ 4 | { 5 | "title": "new block hashes", 6 | "type": "array", 7 | "items": { 8 | "title": "32 byte hex value", 9 | "type": "string", 10 | "pattern": "^0x[0-9a-f]{64}$" 11 | } 12 | }, 13 | { 14 | "title": "new transaction hashes", 15 | "type": "array", 16 | "items": { 17 | "title": "32 byte hex value", 18 | "type": "string", 19 | "pattern": "^0x[0-9a-f]{64}$" 20 | } 21 | }, 22 | { 23 | "title": "new logs", 24 | "type": "array", 25 | "items": { 26 | "title": "log", 27 | "type": "object", 28 | "required": [ 29 | "transactionHash" 30 | ], 31 | "additionalProperties": false, 32 | "properties": { 33 | "removed": { 34 | "title": "removed", 35 | "type": "boolean" 36 | }, 37 | "logIndex": { 38 | "title": "log index", 39 | "type": "string", 40 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 41 | }, 42 | "transactionIndex": { 43 | "title": "transaction index", 44 | "type": "string", 45 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 46 | }, 47 | "transactionHash": { 48 | "title": "transaction hash", 49 | "type": "string", 50 | "pattern": "^0x[0-9a-f]{64}$" 51 | }, 52 | "blockHash": { 53 | "title": "block hash", 54 | "type": "string", 55 | "pattern": "^0x[0-9a-f]{64}$" 56 | }, 57 | "blockNumber": { 58 | "title": "block number", 59 | "type": "string", 60 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 61 | }, 62 | "address": { 63 | "title": "address", 64 | "type": "string", 65 | "pattern": "^0x[0-9,a-f,A-F]{40}$" 66 | }, 67 | "data": { 68 | "title": "data", 69 | "type": "string", 70 | "pattern": "^0x[0-9a-f]*$" 71 | }, 72 | "topics": { 73 | "title": "topics", 74 | "type": "array", 75 | "items": { 76 | "title": "32 hex encoded bytes", 77 | "type": "string", 78 | "pattern": "^0x[0-9a-f]{64}$" 79 | } 80 | } 81 | } 82 | } 83 | } 84 | ] 85 | } 86 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_getFilterLogs.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Filter results", 3 | "oneOf": [ 4 | { 5 | "title": "new block hashes", 6 | "type": "array", 7 | "items": { 8 | "title": "32 byte hex value", 9 | "type": "string", 10 | "pattern": "^0x[0-9a-f]{64}$" 11 | } 12 | }, 13 | { 14 | "title": "new transaction hashes", 15 | "type": "array", 16 | "items": { 17 | "title": "32 byte hex value", 18 | "type": "string", 19 | "pattern": "^0x[0-9a-f]{64}$" 20 | } 21 | }, 22 | { 23 | "title": "new logs", 24 | "type": "array", 25 | "items": { 26 | "title": "log", 27 | "type": "object", 28 | "required": [ 29 | "transactionHash" 30 | ], 31 | "additionalProperties": false, 32 | "properties": { 33 | "removed": { 34 | "title": "removed", 35 | "type": "boolean" 36 | }, 37 | "logIndex": { 38 | "title": "log index", 39 | "type": "string", 40 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 41 | }, 42 | "transactionIndex": { 43 | "title": "transaction index", 44 | "type": "string", 45 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 46 | }, 47 | "transactionHash": { 48 | "title": "transaction hash", 49 | "type": "string", 50 | "pattern": "^0x[0-9a-f]{64}$" 51 | }, 52 | "blockHash": { 53 | "title": "block hash", 54 | "type": "string", 55 | "pattern": "^0x[0-9a-f]{64}$" 56 | }, 57 | "blockNumber": { 58 | "title": "block number", 59 | "type": "string", 60 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 61 | }, 62 | "address": { 63 | "title": "address", 64 | "type": "string", 65 | "pattern": "^0x[0-9,a-f,A-F]{40}$" 66 | }, 67 | "data": { 68 | "title": "data", 69 | "type": "string", 70 | "pattern": "^0x[0-9a-f]*$" 71 | }, 72 | "topics": { 73 | "title": "topics", 74 | "type": "array", 75 | "items": { 76 | "title": "32 hex encoded bytes", 77 | "type": "string", 78 | "pattern": "^0x[0-9a-f]{64}$" 79 | } 80 | } 81 | } 82 | } 83 | } 84 | ] 85 | } 86 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_getLogs.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Filter results", 3 | "oneOf": [ 4 | { 5 | "title": "new block hashes", 6 | "type": "array", 7 | "items": { 8 | "title": "32 byte hex value", 9 | "type": "string", 10 | "pattern": "^0x[0-9a-f]{64}$" 11 | } 12 | }, 13 | { 14 | "title": "new transaction hashes", 15 | "type": "array", 16 | "items": { 17 | "title": "32 byte hex value", 18 | "type": "string", 19 | "pattern": "^0x[0-9a-f]{64}$" 20 | } 21 | }, 22 | { 23 | "title": "new logs", 24 | "type": "array", 25 | "items": { 26 | "title": "log", 27 | "type": "object", 28 | "required": [ 29 | "transactionHash" 30 | ], 31 | "additionalProperties": false, 32 | "properties": { 33 | "removed": { 34 | "title": "removed", 35 | "type": "boolean" 36 | }, 37 | "logIndex": { 38 | "title": "log index", 39 | "type": "string", 40 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 41 | }, 42 | "transactionIndex": { 43 | "title": "transaction index", 44 | "type": "string", 45 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 46 | }, 47 | "transactionHash": { 48 | "title": "transaction hash", 49 | "type": "string", 50 | "pattern": "^0x[0-9a-f]{64}$" 51 | }, 52 | "blockHash": { 53 | "title": "block hash", 54 | "type": "string", 55 | "pattern": "^0x[0-9a-f]{64}$" 56 | }, 57 | "blockNumber": { 58 | "title": "block number", 59 | "type": "string", 60 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 61 | }, 62 | "address": { 63 | "title": "address", 64 | "type": "string", 65 | "pattern": "^0x[0-9,a-f,A-F]{40}$" 66 | }, 67 | "data": { 68 | "title": "data", 69 | "type": "string", 70 | "pattern": "^0x[0-9a-f]*$" 71 | }, 72 | "topics": { 73 | "title": "topics", 74 | "type": "array", 75 | "items": { 76 | "title": "32 hex encoded bytes", 77 | "type": "string", 78 | "pattern": "^0x[0-9a-f]{64}$" 79 | } 80 | } 81 | } 82 | } 83 | } 84 | ] 85 | } 86 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_getProof.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Account proof", 3 | "type": "object", 4 | "required": [ 5 | "address", 6 | "accountProof", 7 | "balance", 8 | "codeHash", 9 | "nonce", 10 | "storageHash", 11 | "storageProof" 12 | ], 13 | "additionalProperties": false, 14 | "properties": { 15 | "address": { 16 | "title": "address", 17 | "type": "string", 18 | "pattern": "^0x[0-9,a-f,A-F]{40}$" 19 | }, 20 | "accountProof": { 21 | "title": "accountProof", 22 | "type": "array", 23 | "items": { 24 | "title": "hex encoded bytes", 25 | "type": "string", 26 | "pattern": "^0x[0-9a-f]*$" 27 | } 28 | }, 29 | "balance": { 30 | "title": "balance", 31 | "type": "string", 32 | "pattern": "^0x([1-9a-f]+[0-9a-f]{0,31})|0$" 33 | }, 34 | "codeHash": { 35 | "title": "codeHash", 36 | "type": "string", 37 | "pattern": "^0x[0-9a-f]{64}$" 38 | }, 39 | "nonce": { 40 | "title": "nonce", 41 | "type": "string", 42 | "pattern": "^0x([1-9a-f]+[0-9a-f]{0,15})|0$" 43 | }, 44 | "storageHash": { 45 | "title": "storageHash", 46 | "type": "string", 47 | "pattern": "^0x[0-9a-f]{64}$" 48 | }, 49 | "storageProof": { 50 | "title": "Storage proofs", 51 | "type": "array", 52 | "items": { 53 | "title": "Storage proof", 54 | "type": "object", 55 | "required": [ 56 | "key", 57 | "value", 58 | "proof" 59 | ], 60 | "additionalProperties": false, 61 | "properties": { 62 | "key": { 63 | "title": "key", 64 | "type": "string", 65 | "pattern": "^0x[0-9a-f]{0,64}$" 66 | }, 67 | "value": { 68 | "title": "value", 69 | "type": "string", 70 | "pattern": "^0x([1-9a-f]+[0-9a-f]{0,31})|0$" 71 | }, 72 | "proof": { 73 | "title": "proof", 74 | "type": "array", 75 | "items": { 76 | "title": "hex encoded bytes", 77 | "type": "string", 78 | "pattern": "^0x[0-9a-f]*$" 79 | } 80 | } 81 | } 82 | } 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_getStorageAt.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "hex encoded bytes", 3 | "type": "string", 4 | "pattern": "^0x[0-9a-f]*$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_getTransactionCount.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "hex encoded unsigned integer", 3 | "type": "string", 4 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_getUncleCountByBlockHash.json: -------------------------------------------------------------------------------- 1 | { 2 | "oneOf": [ 3 | { 4 | "title": "Not Found (null)", 5 | "type": "null" 6 | }, 7 | { 8 | "title": "Uncle count", 9 | "type": "string", 10 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_getUncleCountByBlockNumber.json: -------------------------------------------------------------------------------- 1 | { 2 | "oneOf": [ 3 | { 4 | "title": "Not Found (null)", 5 | "type": "null" 6 | }, 7 | { 8 | "title": "Uncle count", 9 | "type": "string", 10 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_maxPriorityFeePerGas.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Max priority fee per gas", 3 | "type": "string", 4 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_newBlockFilter.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "hex encoded unsigned integer", 3 | "type": "string", 4 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_newFilter.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "hex encoded unsigned integer", 3 | "type": "string", 4 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_newPendingTransactionFilter.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "hex encoded unsigned integer", 3 | "type": "string", 4 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_sendRawTransaction.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "32 byte hex value", 3 | "type": "string", 4 | "pattern": "^0x[0-9a-f]{64}$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_sendTransaction.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "32 byte hex value", 3 | "type": "string", 4 | "pattern": "^0x[0-9a-f]{64}$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_sign.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "65 hex encoded bytes", 3 | "type": "string", 4 | "pattern": "^0x[0-9a-f]{130}$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_signTransaction.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "hex encoded bytes", 3 | "type": "string", 4 | "pattern": "^0x[0-9a-f]*$" 5 | } 6 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_syncing.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Syncing status", 3 | "oneOf": [ 4 | { 5 | "title": "Syncing progress", 6 | "type": "object", 7 | "additionalProperties": false, 8 | "properties": { 9 | "startingBlock": { 10 | "title": "Starting block", 11 | "type": "string", 12 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 13 | }, 14 | "currentBlock": { 15 | "title": "Current block", 16 | "type": "string", 17 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 18 | }, 19 | "highestBlock": { 20 | "title": "Highest block", 21 | "type": "string", 22 | "pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$" 23 | } 24 | } 25 | }, 26 | { 27 | "title": "Not syncing", 28 | "description": "Should always return false if not syncing.", 29 | "type": "boolean" 30 | } 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/eth_uninstallFilter.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "boolean" 3 | } 4 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/rpcschemadebugtrace.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "title": "Generated schema for Root", 4 | "type": "object", 5 | "properties": { 6 | "gas": { 7 | "type": "number" 8 | }, 9 | "failed": { 10 | "type": "boolean" 11 | }, 12 | "returnValue": { 13 | "type": "string" 14 | }, 15 | "structLogs": { 16 | "type": "array", 17 | "items": { 18 | "type": "object", 19 | "properties": { 20 | "pc": { 21 | "type": "number" 22 | }, 23 | "op": { 24 | "type": "string" 25 | }, 26 | "gas": { 27 | "type": "number" 28 | }, 29 | "gasCost": { 30 | "type": "number" 31 | }, 32 | "depth": { 33 | "type": "number" 34 | }, 35 | "stack": { 36 | "type": "array", 37 | "items": { 38 | "type": "string" 39 | } 40 | }, 41 | "storage": { 42 | "type": "object", 43 | "patternProperties": { 44 | "^0x[0-9a-f]{64}$": { 45 | "type": "string", 46 | "pattern": "^0x[0-9a-f]{64}$" 47 | } 48 | } 49 | } 50 | }, 51 | "required": [ 52 | "pc", 53 | "op", 54 | "gas", 55 | "gasCost", 56 | "depth", 57 | "stack" 58 | ] 59 | } 60 | } 61 | }, 62 | "required": [ 63 | "gas", 64 | "failed", 65 | "returnValue", 66 | "structLogs" 67 | ] 68 | } 69 | -------------------------------------------------------------------------------- /rpctypes/jsonschemas/rpcschemahexarray.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Receipt array", 3 | "type": "array", 4 | "items": { 5 | "title": "hex encoded bytes", 6 | "type": "string", 7 | "pattern": "^0x[0-9a-f]*$" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /rpctypes/schemas.go: -------------------------------------------------------------------------------- 1 | package rpctypes 2 | 3 | import ( 4 | _ "embed" 5 | ) 6 | 7 | //go:embed jsonschemas/eth_syncing.json 8 | var RPCSchemaEthSyncing string 9 | 10 | //go:embed jsonschemas/eth_getBlockByNumber.json 11 | var RPCSchemaEthBlock string 12 | 13 | //go:embed jsonschemas/eth_accounts.json 14 | var RPCSchemaAccountList string 15 | 16 | //go:embed jsonschemas/rpcschemasigntxresponse.json 17 | var RPCSchemaSignTxResponse string 18 | 19 | //go:embed jsonschemas/eth_getTransactionByHash.json 20 | var RPCSchemaEthTransaction string 21 | 22 | //go:embed jsonschemas/eth_getTransactionReceipt.json 23 | var RPCSchemaEthReceipt string 24 | 25 | //go:embed jsonschemas/eth_getFilterChanges.json 26 | var RPCSchemaEthFilter string 27 | 28 | //go:embed jsonschemas/eth_feeHistory.json 29 | var RPCSchemaEthFeeHistory string 30 | 31 | //go:embed jsonschemas/eth_createAccessList.json 32 | var RPCSchemaEthAccessList string 33 | 34 | //go:embed jsonschemas/eth_getProof.json 35 | var RPCSchemaEthProof string 36 | 37 | //go:embed jsonschemas/rpcschemadebugtrace.json 38 | var RPCSchemaDebugTrace string 39 | 40 | //go:embed jsonschemas/rpcschemahexarray.json 41 | var RPCSchemaHexArray string 42 | 43 | //go:embed jsonschemas/debug_getBadBlocks.json 44 | var RPCSchemaBadBlocks string 45 | 46 | //go:embed jsonschemas/rpcschemadebugblock.json 47 | var RPCSchemaDebugTraceBlock string 48 | -------------------------------------------------------------------------------- /scripts/clients.mk: -------------------------------------------------------------------------------- 1 | ##@ Clients 2 | HOST?=127.0.0.1 3 | PORT?=8545 4 | CHAIN_ID?=1337 5 | LOADTEST_ACCOUNT?=0x85da99c8a7c2c95964c8efd687e95e632fc533d6 6 | LOADTEST_FUNDING_AMOUNT_ETH?=1010000000 7 | 8 | .PHONY: geth 9 | geth: ## Start a local geth node. 10 | geth \ 11 | --dev \ 12 | --http \ 13 | --http.addr ${HOST} \ 14 | --http.port $(PORT) \ 15 | --http.api admin,debug,web3,eth,txpool,personal,miner,net \ 16 | --verbosity 5 \ 17 | --rpc.gascap 50000000 \ 18 | --rpc.txfeecap 0 \ 19 | --miner.gaslimit 10 \ 20 | --miner.gasprice 1 \ 21 | --gpo.blocks 1 \ 22 | --gpo.percentile 1 \ 23 | --gpo.maxprice 10 \ 24 | --gpo.ignoreprice 2 \ 25 | --dev.gaslimit 100000000000 26 | 27 | .PHONY: anvil 28 | anvil: ## Start a local anvil node. 29 | anvil \ 30 | --host ${HOST} \ 31 | --port $(PORT) \ 32 | --chain-id ${CHAIN_ID} \ 33 | --balance 999999999999999 \ 34 | --block-time 5 \ 35 | --gas-limit 300000000000 36 | 37 | .PHONY: fund 38 | fund: ## Fund the loadtest account with 100k ETH. 39 | eth_coinbase=$$(curl -s -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0", "id": 2, "method": "eth_accounts", "params": []}' http://${HOST}:${PORT} | jq -r ".result[0]"); \ 40 | hex_funding_amount=$$(echo "obase=16; ${LOADTEST_FUNDING_AMOUNT_ETH}*10^18" | bc); \ 41 | echo $$eth_coinbase $$hex_funding_amount; \ 42 | curl \ 43 | -H "Content-Type: application/json" \ 44 | -d '{"jsonrpc":"2.0", "method":"eth_sendTransaction", "params":[{"from": "'$$eth_coinbase'","to": "${LOADTEST_ACCOUNT}","value": "0x'$$hex_funding_amount'"}], "id":1}' \ 45 | -s \ 46 | http://${HOST}:${PORT} | jq 47 | 48 | .PHONY: loadtest 49 | loadtest: fund ## Run random loadtest against a local RPC. 50 | sleep 2 51 | go run -race main.go loadtest \ 52 | --verbosity 700 \ 53 | --rpc-url http://${HOST}:$(PORT) \ 54 | --mode random \ 55 | --concurrency 1 \ 56 | --requests 200 \ 57 | --rate-limit 100 \ 58 | --sending-address-count 10 \ 59 | --pre-fund-sending-addresses \ 60 | --summarize 61 | 62 | -------------------------------------------------------------------------------- /scripts/lint.mk: -------------------------------------------------------------------------------- 1 | ##@ Lint 2 | 3 | # Add missing and remove unused modules. 4 | .PHONY: tidy 5 | tidy: 6 | go mod tidy 7 | 8 | # Run `go fmt` against code. 9 | .PHONY: fmt 10 | fmt: 11 | go fmt ./... 12 | 13 | # Run `go vet` and `shadow` (which reports shadowed variables) against code. 14 | # https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/shadow 15 | # `go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest` 16 | .PHONY: vet 17 | vet: 18 | go vet ./... 19 | shadow ./... 20 | 21 | # Run `golangci-lint` against code. 22 | # `golangci-lint` runs `gofmt`, `govet`, `staticcheck` and other linters. 23 | # https://golangci-lint.run/usage/install/#local-installation 24 | .PHONY: golangci-lint 25 | golangci-lint: 26 | golangci-lint run --fix --timeout 5m 27 | 28 | .PHONY: lint 29 | lint: tidy vet golangci-lint ## Run linters. 30 | -------------------------------------------------------------------------------- /scripts/rpctypes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This script takes an argument of the dest directory for the rpc types json file 3 | # Usage: ./rpctypes.sh rpctypes/schemas/ 4 | readonly url="https://github.com/ethereum/execution-apis.git" 5 | readonly commit_id="0c18fb0" 6 | readonly dest="tmp/execution-apis" 7 | readonly schema_dest="schemas" 8 | 9 | rm -rf "./$dest" 10 | git clone "$url" "$dest" 11 | pushd "$dest" || exit 12 | git checkout "$commit_id" 13 | 14 | npm install 15 | npm run build 16 | 17 | # shellcheck disable=SC2207 18 | methods=($(jq -r '.methods[].name' openrpc.json | sort)) 19 | 20 | mkdir "$schema_dest" 21 | echo "Methods:" 22 | for method in "${methods[@]}"; do 23 | echo "Generating schemas for: $method" 24 | jq --arg methodName "$method" '.methods[] | select(.name == $methodName) | .result.schema' openrpc.json > "$schema_dest/$method.json" 25 | done 26 | popd || exit 27 | 28 | mkdir -p "./$1" 29 | echo "Copying schemas to $1..." 30 | cp -f $dest/$schema_dest/* "$1" 31 | -------------------------------------------------------------------------------- /sonar-project.properties: -------------------------------------------------------------------------------- 1 | sonar.projectKey=0xPolygon_polygon-cli_AYYwjbzmo7MiTaKfMGkx 2 | -------------------------------------------------------------------------------- /util/convert.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "encoding/hex" 5 | "math/big" 6 | "strings" 7 | 8 | "github.com/rs/zerolog/log" 9 | ) 10 | 11 | // HexToBigInt converts a hexadecimal string to a big integer. 12 | func HexToBigInt(hexString string) (*big.Int, error) { 13 | // Clean up the string. 14 | // - Remove the `0x` prefix. 15 | // - If the length of the string is odd, pad it with a leading zero. 16 | hexString = strings.TrimPrefix(hexString, "0x") 17 | if len(hexString)%2 != 0 { 18 | log.Trace().Str("original", hexString).Msg("Hexadecimal string of odd length padded with a leading zero") 19 | hexString = "0" + hexString 20 | } 21 | 22 | // Decode the hexadecimal string into a byte slice and return the `big.Int` value. 23 | rawGas, err := hex.DecodeString(hexString) 24 | if err != nil { 25 | log.Error().Err(err).Str("hex", hexString).Msg("Unable to decode hex string") 26 | return nil, err 27 | } 28 | bigInt := big.NewInt(0) 29 | bigInt.SetBytes(rawGas) 30 | return bigInt, nil 31 | } 32 | -------------------------------------------------------------------------------- /util/log.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/rs/zerolog" 8 | "github.com/rs/zerolog/log" 9 | ) 10 | 11 | // VerbosityLevel represents the verbosity levels. 12 | // https://pkg.go.dev/github.com/rs/zerolog#readme-leveled-logging 13 | type VerbosityLevel int 14 | 15 | const ( 16 | Silent VerbosityLevel = 0 17 | Panic VerbosityLevel = 100 18 | Fatal VerbosityLevel = 200 19 | Error VerbosityLevel = 300 20 | Warn VerbosityLevel = 400 21 | Info VerbosityLevel = 500 22 | Debug VerbosityLevel = 600 23 | Trace VerbosityLevel = 700 24 | ) 25 | 26 | // SetLogLevel sets the log level based on the flags. 27 | // https://logging.apache.org/log4j/2.x/manual/customloglevels.html 28 | func SetLogLevel(verbosity int) { 29 | switch { 30 | case verbosity == int(Silent): 31 | zerolog.SetGlobalLevel(zerolog.NoLevel) 32 | case verbosity <= int(Panic): 33 | zerolog.SetGlobalLevel(zerolog.PanicLevel) 34 | case verbosity <= int(Fatal): 35 | zerolog.SetGlobalLevel(zerolog.FatalLevel) 36 | case verbosity <= int(Error): 37 | zerolog.SetGlobalLevel(zerolog.ErrorLevel) 38 | case verbosity <= int(Warn): 39 | zerolog.SetGlobalLevel(zerolog.WarnLevel) 40 | case verbosity <= int(Info): 41 | zerolog.SetGlobalLevel(zerolog.InfoLevel) 42 | case verbosity <= int(Debug): 43 | zerolog.SetGlobalLevel(zerolog.DebugLevel) 44 | default: 45 | zerolog.SetGlobalLevel(zerolog.TraceLevel) 46 | } 47 | } 48 | 49 | // LogMode represents the logger mode. 50 | type LogMode string 51 | 52 | const ( 53 | Console LogMode = "console" 54 | JSON LogMode = "json" 55 | ) 56 | 57 | // SetLogMode updates the log format. 58 | func SetLogMode(mode LogMode) error { 59 | switch mode { 60 | case Console: 61 | log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}) 62 | log.Trace().Msg("Starting logger in console mode") 63 | case JSON: 64 | log.Trace().Msg("Starting logger in JSON mode") 65 | default: 66 | return fmt.Errorf("unsupported log mode: %s", mode) 67 | } 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /util/send.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "context" 5 | "crypto/ecdsa" 6 | "math/big" 7 | 8 | "github.com/ethereum/go-ethereum/accounts/abi/bind" 9 | "github.com/ethereum/go-ethereum/common" 10 | "github.com/ethereum/go-ethereum/core/types" 11 | "github.com/ethereum/go-ethereum/crypto" 12 | "github.com/ethereum/go-ethereum/ethclient" 13 | ) 14 | 15 | // SendTx is a simple wrapper to send a transaction from one Ethereum address to another. 16 | func SendTx(ctx context.Context, c *ethclient.Client, privateKey *ecdsa.PrivateKey, to *common.Address, amount *big.Int, data []byte, gasLimit uint64) error { 17 | // Get the chaind id. 18 | chainID, err := c.ChainID(ctx) 19 | if err != nil { 20 | return err 21 | } 22 | 23 | // Get the nonce. 24 | from := crypto.PubkeyToAddress(privateKey.PublicKey) 25 | var nonce uint64 26 | nonce, err = c.PendingNonceAt(ctx, from) 27 | if err != nil { 28 | return err 29 | } 30 | 31 | // Get suggested gas price. 32 | var gasPrice *big.Int 33 | gasPrice, err = c.SuggestGasPrice(ctx) 34 | if err != nil { 35 | return err 36 | } 37 | 38 | // Create and sign the transaction. 39 | tx := types.NewTx(&types.LegacyTx{ 40 | Nonce: nonce, 41 | Gas: gasLimit, 42 | GasPrice: gasPrice, 43 | To: to, 44 | Value: amount, 45 | Data: data, 46 | }) 47 | var signedTx *types.Transaction 48 | signedTx, err = types.SignTx(tx, types.NewEIP155Signer(chainID), privateKey) 49 | if err != nil { 50 | return err 51 | } 52 | 53 | // Send the transaction. 54 | if err = c.SendTransaction(ctx, signedTx); err != nil { 55 | return err 56 | } 57 | if _, err = bind.WaitMined(ctx, c, signedTx); err != nil { 58 | return err 59 | } 60 | return nil 61 | } 62 | -------------------------------------------------------------------------------- /util/url.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "net/url" 7 | 8 | "github.com/rs/zerolog/log" 9 | ) 10 | 11 | // ValidateUrl checks if a string URL can be parsed and if it has a valid scheme. 12 | func ValidateUrl(input string) error { 13 | url, err := url.Parse(input) 14 | if err != nil { 15 | log.Error().Err(err).Msg("Unable to parse url input error") 16 | return err 17 | } 18 | 19 | if url.Scheme == "" { 20 | return errors.New("the scheme has not been specified") 21 | } 22 | switch url.Scheme { 23 | case "http", "https", "ws", "wss": 24 | return nil 25 | default: 26 | return fmt.Errorf("the scheme '%s' is not supported", url.Scheme) 27 | } 28 | } 29 | --------------------------------------------------------------------------------