Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transaction signing capabilities #67

Merged
merged 27 commits into from
Dec 26, 2023
Merged

Conversation

alisina-nl
Copy link

This PR adds the following features to Ethers:

  • A Signer behaviour which has mandatory callbacks for listing accounts and signing transactions.
  • Two built-in signer implementations:
    • Signer.Local: A local signer which signs transactions and lists accounts (a single account) using a 256bit private key.
    • Signer.JsonRPC: A signer which delegates the transaction signing to a RPC server (like web3siger or geth) using the eth_signTransaction and eth_accounts functions.
  • Transaction struct with support for encoding EIP-1559 and Legacy transactions.
  • A new Ethers.sign_transaction/2 function which returns signed payload of a transaction.
  • Accepting signer and signer_opts options in Ethers.send/2 and Ethers.deploy/2 functions.
  • Updated documentation (+ README.md) with the new signer.

Closes fortelabsinc#1

@wchenNL
Copy link
Contributor

wchenNL commented Dec 21, 2023

while testing with this branch found a few very minor things which may not be related to this PR:

  • default_address is required otherwise a {:error, :no_to_address} is returned, so I guess it's not really optional?
  • extra comma in the readme at this line
    default_signer_opts: [] # Defaults to: []

@alisinabh
Copy link
Member

  • default_address is required otherwise a {:error, :no_to_address} is returned, so I guess it's not really optional?

This is true. If you don't provide the default address you MUST specify to address when calling or sending a transaction. In that case you can do it like this (in the second argument of send/call function):

MyERC20Token.name()
|> Ethers.call(to: "0xContract Address Here")

If this is not well communicated in the docs maybe we should improve them.

@alisinabh alisinabh requested a review from wchenNL December 22, 2023 19:01
Copy link
Contributor

@wchenNL wchenNL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@alisinabh alisinabh merged commit a8c1e4e into ExWeb3:main Dec 26, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support both Type 0 and Type 2 transaction
3 participants