Auto-generated documentation.
Sign tx data.
polycli signer sign [flags]Currently, polycli only supports signing transactions. Message and arbitrary signing might happen in the future. In order to sign as message we first need to create some transaction data in a JSON file
{
"from": "0xB41C20404dffA411fd3F5453a9EA4432Da64e70b",
"to": "0xB41C20404dffA411fd3F5453a9EA4432Da64e70b",
"gas": "0x8000",
"gasPrice": "0x30000000",
"maxFeePerGas": "0x30000000",
"maxPriorityFeePerGas": "0x30000000",
"value": "0x1",
"nonce": "0x0",
"input": "",
"chainId": "0x539",
"accessList": []
}The file format here is defined by SendTxArgs in go-ethereum. This is a lower level transaction format and it will require you to manually specify things like nonce and gasPrice. In other libraries these are often computed for you.
The benefit here is that it gives us the ability to specify lower level options like accessList which aren't usually available in other libraries.
Assuming we have valid transaction data in tx.json we can sign the transaction three different ways depending on where our private key is stored
This is the easiest, but least secure way to sign. In this case, we're providing a private key as a command line argument to polycli and using that to sign the transaction data. The signed transaction is written to stdout
polycli signer sign --private-key $(cat private-key.txt) --data-file tx.json --chain-id 1337 | jq '.'This is the output that is generated. signedTx is the JSON formatted transaction which is readable but not readily usable. The rawSignedTx can be directly published.
{
"rawSignedTx": "02f86c820539808430000000843000000082800094b41c20404dffa411fd3f5453a9ea4432da64e70b0180c080a0978b7e99d4941fddcbfc792632a53bd4ac4b690ae4395d8203ecec9836e53dd8a00e32626e8456afb6e59f1fb2a8835bd647a97fec4d9da6a46ecadbf310b345d6",
"signedTx": {
"type": "0x2",
"chainId": "0x539",
"nonce": "0x0",
"to": "0xb41c20404dffa411fd3f5453a9ea4432da64e70b",
"gas": "0x8000",
"gasPrice": null,
"maxPriorityFeePerGas": "0x30000000",
"maxFeePerGas": "0x30000000",
"value": "0x1",
"input": "0x",
"accessList": [],
"v": "0x0",
"r": "0x978b7e99d4941fddcbfc792632a53bd4ac4b690ae4395d8203ecec9836e53dd8",
"s": "0xe32626e8456afb6e59f1fb2a8835bd647a97fec4d9da6a46ecadbf310b345d6",
"yParity": "0x0",
"hash": "0xc03d220111f2d10b6a2b6b22c98e0e7e728a869cac0d3730e33b8bff683d677d"
}
}Signing with a keystore requires that you specify the --keystore location and the --key-id which in this case is the address of the key that you'd like to use for signing
polycli signer sign --keystore /tmp/keystore --key-id 0x58ce4bE73Ee7D0dee75395Ef662e98F91AD2E740 --data-file tx.json --chain-id 1337The syntax for signing with KMS should look familiar.
# polycli assumes that there is default login that's been done already
gcloud auth application-default login
polycli signer sign --kms GCP --gcp-project-id prj-polygonlabs-devtools-dev --key-id jhilliard-trash --data-file tx.json --chain-id 1337 -h, --help help for signThe command also inherits flags from parent commands.
--chain-id uint chain ID for transactions
--config string config file (default is $HOME/.polygon-cli.yaml)
--data-file string file name holding data to be signed
--gcp-import-job-id string GCP import job ID to use when importing key
--gcp-key-version int GCP crypto key version to use (default 1)
--gcp-keyring-id string GCP keyring ID to be used (default "polycli-keyring")
--gcp-location string GCP region to use (default "europe-west2")
--gcp-project-id string GCP project ID to use
--key-id string ID of key to be used for signing
--keystore string use keystore in given folder or file
--kms string AWS or GCP if key is stored in cloud
--pretty-logs output logs in pretty format instead of JSON (default true)
--private-key string use provided hex encoded private key
--type string type of signer to use: latest, cancun, london, eip2930, eip155 (default "london")
--unsafe-password string non-interactively specified password for unlocking keystore
-v, --verbosity string log level (string or int):
0 - silent
100 - panic
200 - fatal
300 - error
400 - warn
500 - info (default)
600 - debug
700 - trace (default "info")- polycli signer - Utilities for security signing transactions.