When building a dApp, there are multiple data sources to be consumed. It could be from decentralized data source, like on-chain data. Or it can be from some centralized products, like Etherscan, DeBank.
The integration of those data can be complex sometimes. talks-to-web3.js
is aimed to simplify this.
It will provide the following functions:
- Integrated common used on-chain data provider and operations.
- Integrated multiple centralized existing products and services.
- Modularized Scability
src/protocols
: wrap operation that interact with smart contractssrc/products
: wrap operation that intereact with third-party productssrc/agents
: wrap operations based onprotocols
andproducts
Usually, the data requested from on-chain is current and direct data. It cannot get the accumulated data unless the protocol has recorded it as a smart contract variable.
For some complex data, multiple on-chain data source and some calculations are required. Usually it uses multicall
contract to get all the required data at once.
For some other data, retrival may be required. In this kind of situation, a centralized service is necessary.
Generally, there are three kinds of data when building a dapp.
- Data without connecting to a wallet
- Data after connecting to a wallet(specifily related to one connected wallet)
- Operate a transation
For the first kind of data, it's usually protocol level data. For example, the general APY, TVL etc...
For the second kind of data, it's usually strong related to one specific account. It will be used only after a wallet has been connected.
For the third kind of data, sign a message or transaction is required. It will be used only after a wallet has been connected.
- run
cp .env.example .env
and fill out related info in.env
- try
node examples/welcome.js
- write your own scripts with your own requirements
- add more common used abis
can be found here: https://chainid.network/chains.json