Package Exports
- @klaytn/ethers-ext
- @klaytn/ethers-ext/dist/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@klaytn/ethers-ext) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Ethers.js Extension for Klaytn
Ethers.js Extension for Klaytn offers:
- Drop-in replacement to
ethers.Walletthat handles both Ethereum and Klaytn transactions involving AccountKey and TxTypes. - Drop-in replacement to
ethers.JsonRpcProviderthat provides Ethereum RPC as well as Klaytn-specific RPCs. - AccountStore to manage Klaytn account keys.
Install
npm install --save @klaytn/ethers-extUsage
See examples.
Build
Install dependencies
npm install(optional) Import @klaytn/web3rpc from local file. Use this method to use the latest version of the web3rpc.
npm link ../web3rpc/sdk/client/javascript/openapiBuild the library
npm run buildRun examples
node example/rpc/rpc.js
Core classes
classDiagram
FieldType ..|> FieldTypeBytes
FieldType ..|> FieldTypeSignatureTuples
FieldType ..|> FieldTypeAccountKey
FieldType ..|> etc
class FieldType {
<<interface>>
canonicalize(any): any
emptyValue(): any
}
class FieldTypeBytes {
canonicalize(any): string
emptyValue(): string
}
class FieldTypeSignatureTuples {
canonicalize( SignatureLike[]): SignatureTuple[]
emptyValue(): SignatureTuple[]
}
class FieldTypeAccountKey {
canonicalize(TypedAccountKey | string | any): string
emptyValue(): string
}classDiagram
FieldSet <|-- KlaytnTx
KlaytnTx <|-- TxTypeValueTransfer
KlaytnTx <|-- TxTypeFeeDelegatedValueTransfer
KlaytnTx <|-- other TxTypes
FieldSet <|-- AccountKey
AccountKey <|-- AccountKeyLegacy
AccountKey <|-- AccountKeyPublic
AccountKey <|-- other AccountKey
class FieldSet {
type: number
typeName: string
fieldTypes: string -> FieldType
setFields(any)
setFieldsFromArray( string[], any[] )
getField( string ): any
getFields( string[] ): any[]
toObject(): any
}
class KlaytnTx {
sigRLP(): string
sigFeePayerRLP(): string
senderTxHashRLP(): string
txHashRLP(): string
addSenderSig(sig)
addFeePayerSig(sig)
setFieldsFromRLP(string): void
}
class AccountKey {
toRLP(): string
}classDiagram
FieldSetFactory <|.. KlaytnTxFactory
FieldSetFactory <|.. AccountKeyFactory
class FieldSetFactory {
private registry: [number] -> FieldSet
private requiredFields: string[]
add(typeof T)
has(type?): boolean
lookup(type?): typeof T
fromObject(any): T
}
class KlaytnTxFactory {
fromRLP(string): KlaytnTx
}
class AccountKeyFactory {
}ethers extension classes
classDiagram
ethers_Wallet <|-- KlaytnWallet
ethers_Signer <|-- ethers_Wallet
class ethers_Signer {
provider
abstract getAddress()
abstract signMessage()
abstract signTransaction()
sendTransaction()
}
class ethers_Wallet {
address
privateKey
getAddress()
signMessage()
signTransaction()
checkTransaction()
populateTransaction()
sendTransaction()
}
class KlaytnWallet {
signTransaction()
checkTransaction()
populateTransaction()
sendTransaction()
}
ethers_Provider <|-- ethers_BaseProvider
ethers_BaseProvider <|-- ethers_JsonRpcProvider
ethers_JsonRpcProvider <|-- KlaytnJsonRpcProvider
class ethers_Provider {
abstract sendTransaction()
abstract call()
abstract estimateGas()
}
class ethers_BaseProvider {
sendTransaction()
waitForTransaction()
}
class ethers_JsonRpcProvider {
perform()
send()
prepareRequest() // "eth_sendRawTransaction"
}
class KlaytnJsonRpcProvider {
sendTransaction()
prepareRequest() // "klay_sendRawTransaction"
}