ethers-io / ethers.js

Complete Ethereum library and wallet implementation in JavaScript.
https://ethers.org/
MIT License
7.91k stars 1.84k forks source link

Adding support for klaytn. #644

Closed benjioh5 closed 4 years ago

benjioh5 commented 4 years ago

Klaytn is one of forked version of Ethereum and it aims enterprise usage of blockchain. I saw #351 is accepted and I wonder kalytn's mainnet (cypress) and testnet (baobab) can be added. Klaytn has some few change of transaction model (e.g. adding fee delegation) but It's usally competible with ethereum's own structure.

Could I make some test cases and add for it?

ricmoo commented 4 years ago

The only change required for ETC was adding backends to the list of common/known networks.

Changes to the Transaction serialization is far more substantial, but you can look at the @ethersproject-aion packages and related repository for an idea of how to extend ethers v5 to support new slightly different networks. I did the Aion library on behalf of a grant they provided, but in general supporting a new Etehreum-fork is outside of what I have time to do. :)

ricmoo commented 4 years ago

I'm going to close this now, but please feel free to re-open or continue discussion. I monitor closed issues.

Thanks! :)

benjioh5 commented 4 years ago

Sorry for late comment.

Klaytn supports LEGACY mode (original Ethereum Tx) and DELEGATE_FEE mode. I think @ethersproject-aion would be good example for forking, but LEGACY mode is good enough for using klaytn. (Actually DELEGATE_FEE transaction is not yet widely used in klaytn network.)

Klaytn's caver-js's provider fully supports etherjs's HttpProvider method.

import { ethers } from 'ethers';
const Caver = require('caver-js') // forked version of web3js
const caver = new Caver('https://api.baobab.klaytn.net:8651/')

provider = new caver.providers.HttpProvider(`https://api.baobab.klaytn.net:8651/`);
provider = new ethers.providers.Web3Provider(provider);
// It Works!

Then I just want to add network information to etherjs. And I'll maintain or take care about klaytn's modified version of fee delegation transaction. It would be easy work for just adding provider for klaytn and then forks ethersjs for ethersjs-klaytn.

Thanks! :)

taalswap commented 2 years ago

After send a transaction to Klaytn busing ethers.js const tx = await contract.method(parameters, ...overrides)

To receive the receipt const receipt = await tx.wait()

Then... ethers.js emit an error: _Unhandled Rejection (Error): invalid BigNumber string (argument="value", value="TxTypeLegacyTransaction", code=INVALIDARGUMENT, version=bignumber/5.5.0)

I think that Klaytn guys need to support ethers.js urgently to extend their dApp ecosystem because many dApps running already on ethereum, binance and so on are using ethers.js not caver-js

benjioh5 commented 2 years ago

I found Klaybank team made some forked version for klaytn. Is there any chance to review this and make it official klaytn ethersjs version?

https://github.com/klaybank/ethers_providers_klaytn

@ricmoo

ricmoo commented 2 years ago

I would love to check it out.

I’m working on a v6 Network for Klatyn, so seeing differences will help.

In v6, a simple Network object can override a lot of provide behaviour, so it makes ethers behave frictionlessly with other chains. :)