Skip to main content

KMS signer for Ethereum

Project description

eth_kms_signer

codecov PyPI Downloads PyPI - License Documentation Status

AWS KMS Signer for ETH transactions(EIP 155/EIP 1559/ EIP 2930)

>> Go to documentation

Dependencies

  • Python 3.5+

QuickStart

This library is available on PyPI. Install via pip as:

  pip install eth-kms-signer

Usage

  1. Instantiate eth kms signer client
from eth_kms_signer import EthKmsClient

client = EthKmsClient(region_name="{aws-kms-region}")
  1. Initailize web3
from web3 import Web3

w3 = Web3(Web3.HTTPProvider(endpoint_uri="{rpc_url}"))
  1. Sign a EIP 155 transaction
tx = {
    "nonce": nonce,
    "to": "0x7EeD368F105a6eaC9Ac645bC3440fEa9A6C3D531",
    "value": w3.toWei(12, "wei"),
    "gas": 21000,
    "gasPrice": w3.toWei(1, "gwei"),
    "chainId": "0x4",
}
signed_tx = client.sign_transaction(tx, key_id)
tx_hash = w3.eth.sendRawTransaction(signed_tx)
  1. Sign a EIP 1559 Dynamic Fee transaction
tx = {
    "nonce": nonce,
    "to": "0x7EeD368F105a6eaC9Ac645bC3440fEa9A6C3D531",
    "value": w3.toWei(12, "wei"),
    "gas": 21000,
    "maxFeePerGas": w3.toWei(1, "gwei"),
    "maxPriorityFeePerGas": w3.toWei(1, "gwei"),
    "type": "0x2",
    "chainId": "0x4",
}
signed_tx = client.sign_transaction(tx, key_id)
tx_hash = w3.eth.sendRawTransaction(signed_tx)

Examples

Choose one of the following for a fully detailed example:

Terraform to provision AWS KMS Key

The following example makes use of the CloudPosse Terraform Module:

Detailed Example

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kms_signer-0.1.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file kms_signer-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: kms_signer-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for kms_signer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1813944ca42886dd236066c020a092dc6c622ea6ed3cd72bd7033c963bcc510a
MD5 41ab46d9b05095cea3b68c0cb316129e
BLAKE2b-256 2364e43512d7dd8792db2600ee12fc311989bd32cefe81fa29321f7bd5df6636

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page