polygon-cli

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2022 License: LGPL-3.0 Imports: 1 Imported by: 0

README

#+TITLE: Polygon CLI
#+DATE:
#+AUTHOR: John Hilliard
#+EMAIL: jhilliard@polygon.technology
#+CREATOR: John Hilliard
#+DESCRIPTION:


#+OPTIONS: toc:nil
#+LATEX_HEADER: \usepackage{geometry}
#+LATEX_HEADER: \usepackage{lmodern}
#+LATEX_HEADER: \geometry{left=1in,right=1in,top=1in,bottom=1in}
#+LaTeX_CLASS_OPTIONS: [letterpaper]


* Hash
#+begin_src bash
$ echo -n "hello" > hello.txt
$ polycli hash sha1 --file hello.txt
aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
$ echo -n "hello" | polycli hash sha1
aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
$ polycli hash sha1 hello
aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
#+end_src

* Mnemonic
#+begin_src bash
$ polycli mnemonic
enact only hair era deposit coffee key swing chief dilemma vivid owner helmet jazz trigger caught gather sister mutual uncover hedgehog undo slush else
$ polycli mnemonic --language spanish
aire mecha vino álbum bazar cerca barro perro crónica opinar finito cocina aduana límite abuso ronda croqueta huracán violín niño rodar riñón pilar fumar
$ polycli mnemonic --language spanish --words 12
sardina momento ruta rulo truco mochila pronto varón adicto rehén ajuste bebida
#+end_src

* Wallet

Create an avail style wallet:
#+begin_src bash
polycli wallet create --raw-entropy --root-only --words 15 --language english
#+end_src


Inspect an avail style wallet that uses a password
#+begin_src bash
polycli wallet inspect --raw-entropy --root-only --language english --password "Substrate" --mnemonic "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
#+end_src

Generate 5 addresses for BTC:
#+begin_src bash
polycli wallet create --path "m/44'/0'/0'" --addresses 5
#+end_src

Generate 5 addresses for ETH:
#+begin_src bash
polycli wallet create --path "m/44'/60'/0'" --addresses 5
#+end_src

Generate 5 addresses for MATIC:
#+begin_src bash
polycli wallet create --path "m/44'/966'/0'" --addresses 5
#+end_src


* Adding Commands
Script to setup this repo
#+BEGIN_SRC bash
cobra-cli init
cobra-cli add version
cobra-cli add hash
cobra-cli add mnemonic
#+END_SRC


This is the content of my ~~/.cobra.yaml~ file
#+begin_src yaml
---
author: Polygon <engineering@polygon.technology>
license: lgpl-3.0
useViper: true
#+end_src


* Reference


- https://github.com/spf13/cobra-cli/blob/main/README.md


local geth testing
./build/bin/geth --dev --http --http.addr localhost --http.port 8546 --http.api eth,web3,personal,net --verbosity 5
./build/bin/geth --dev --dev.period 2 --http --http.addr localhost --http.port 8546 --http.api eth,web3,personal,net --verbosity 5

./build/bin/geth attach http://127.0.0.1:8545
> eth.coinbase==eth.accounts[0]
> eth.sendTransaction({from: eth.coinbase, to: "0x85da99c8a7c2c95964c8efd687e95e632fc533d6", value: web3.toWei(5000, "ether")})

Test account:
code code code code code code code code code code code quality




socat - UNIX-CONNECT:/var/folders/zs/k8swqskj1t79cgnjh6yt0fqm0000gn/T/geth.ipc
{"id": 1, "method": "eth_subscribe", "params": ["newHeads"]}


curl -v -H 'Content-Type: application/json' -d '{"id": 1, "method": "net_version", "params": []}' 172.26.26.12:8545

curl -v -H 'Content-Type: application/json' -d '{"id": 1, "method": "eth_getBlockByNumber", "params": ["0x1DE8531", true]}' https://polygon-rpc.com
curl -v -H 'Content-Type: application/json' -d '{"id": 1, "method": "clique_getSigner", "params": ["0x1DE8531", true]}' https://polygon-rpc.com



curl -v -H 'Content-Type: application/json' -d '{"id": 1, "method": "eth_subscribe", "params": ["newHeads"]}' ws://127.0.0.1:8545

telnet 172.26.26.12 8545
POST / HTTP/1.1
Host: 172.26.26.12:8545
Content-Type: application/json



telnet 127.0.0.1 8545
POST / HTTP/1.1
Host: 127.0.0.1:8545
Content-Type: application/json

{"id": 1, "method": "eth_subscribe", "params": ["newHeads"]}


curl -v -H 'Content-Type: application/json' -d '{"id": 1, "method": "eth_blockNumber", "params": []}' http://127.0.0.1:8888
curl -v -H 'Content-Type: application/json' -d '{"id": 1, "method": "eth_getBlockByNumber", "params": ["0x7d57", true]}' http://127.0.0.1:8888
curl -v -H 'Content-Type: application/json' -d '{"id": 1, "method": "eth_getBalance", "params": ["0x85da99c8a7c2c95964c8efd687e95e632fc533d6", "latest"]}' http://127.0.0.1:8888
curl -v -H 'Content-Type: application/json' -d '{"id": 1, "method": "eth_getCode", "params": ["0x79954f948079ee9ef1d15eff3e07ceaef7cdf3b4", "latest"]}' http://127.0.0.1:8888

curl -v -H 'Content-Type: application/json' -d '{"id": 1, "method": "eth_getBlockByNumber", "params": ["0x813C", true]}' http://127.0.0.1:8888


go run main.go loadtest --verbosity 700 --chain-id 1256 --concurrency 1 --requests 1000 --rate-limit 1 http://localhost:8888 --mode t

Use this command to get a block that's close to the gas cap... It' wil make 50 requests over 100 sections where each TX is very close to the limit of 50000000 gas
./linux-amd64-polycli loadtest --verbosity 700 --chain-id 1256 --concurrency 1 --requests 50 --rate-limit 0.5 http://private.validator-002.devnet02.pos-v3.polygon.private:8545 --mode f --function 164 --iterations 25078
./linux-amd64-polycli loadtest --verbosity 700 --chain-id 1256 --concurrency 1 --requests 50 --rate-limit 0.5 http://private.validator-001.devnet02.pos-v3.polygon.private:8545 --mode f --function 164 --iterations 25078

Documentation

Overview

Copyright © 2022 Polygon <engineering@polygon.technology>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL