Skip to content

Feature Support & Comparison

Taylor Dawson edited this page Jul 5, 2019 · 10 revisions

Details about web3.js & ethers.js

References:

Feature Web3.js Ethers.js Support in Web3data.js Notes
getAccount
getHashrate × ×
getGasPrice Web3.js returns "20000000000", ethers returns: "20000000000", use endpoint: https://docs.amberdata.io/reference/transactions#get-gas-predictions using fastest or average
getAccounts ×
getBlockNumber Web3.js — type number, 7280000
Ethers — type number, 7280000
Endpoint— /block/:id using the blocks.current
getBalance Web3.js — type string
Ethers — type BigNumber
Endpoint — /addresses/:hash/account-balances/latest .value
getStorageAt ×
getCode Web3.js — type string
Ethers — type string
Endpoint— /contracts/:hash .bytecode
getBlock Web3.js — type object response
Ethers — type object response
Endpoint— /blocks/:id?validationMethod=full
getBlockTransactionCount × Web3.js — type number
Endpoint— /blocks/:id .numTransactions
getUncle × Web3.js — type object response
Endpoint— /blocks/:id?validationMethod=full .validations.unlces
This should be evaluated since we just want uncles but it returns a lot of extra data; it also seems like this is subject to change. See AL-1874.
getTransaction Web3.js — type object response
Ethers — type object response
Endpoint— /transactions/:hash
getPendingTransactions × Web3.js — type object response
Endpoint— /transactions?status=pending
getTransactionFromBlock × Web3.js — type object response
Endpoint— /blocks/:id/transactions payload.records[index] to retrieve by block and index
getTransactionReceipt ?
getTransactionCount Web3.js — type number
Ethers — type BigNumber
Endpoint— currently I don't think this is possible
sendTransaction ×
sendSignedTransaction × ×
sign ×
signTransaction ×
call ×
estimateGas ×
getPastLogs Web3.js — type arrayof objects response
Ethers getLogs() — type array of Log objects response
Endpoint— /addresses/:hash/logs
This one is really wonky, web3js gets ALL past logs. ethersjs can only get past logs of a specific contract, same with our endpoint as seen above. Only this /search/logs endpoint can do that.
getWork × ×
submitWork × ×
getChainId Web3.js — type string
Ethers — type object network.chainId
Endpoint— ???????????
Contract.getPastEvents × Web3.js — type array of objects response
Ethers getLogs() — type array of Log objects response
Endpoint— /addresses/:hash/logs
utils ?
getEtherPrice × × Web3.js — type
Ethers — type didn’t see this for ethersjs
Endpoint

† All endpoints return lots of data points that may require direct comparisons.

Websockets

Feature Web3.js Ethers.js Support in Web3data.js Notes
Contract.on
Contract.once
Contract.events.MyEvent ✓^ ? Ethers.js - Only available via filters
Contract.events.allEvents ✓^ ? Ethers.js - Only available via filters
Clone this wiki locally