ContractCreator: 0xdd9176ea3e7559d6b68b537ef555d3e89403f742 at txn [0xa7eba644182d78c4568364](https://basescan.org/tx/0xa7eba644182d78c4568364e00b0320a9fde9c1fe779cdbec6941fb7443d14c01)
:
friendtech-by-chainstack
directory. Specifically, we’re going to focus on the following files:
subgraph.yaml
schema.graphql
src/friendtech-shares-v-1.ts
subgraph.yaml
file, you can find the following code:
entities
that will be created in the database to store the smart contract events data and eventHandlers
that also can be used in the subgraph code and the paths to the other source code files.
If we open the file called schema.graphql
, we see the actual structure of the tables with data:
Trade
table is what we need. It contains the following entries:
trader
— the address of the tradersubject
— the address of the influencerisBuy
— the direction of saleshareAmount
— the number of shares in the tradeethAmount
— the price of the share in the dealsubjectEthAmount
— the fee that is received by the influencerprotocolEthAmount
field is the fee that is received by the protocolsupply
— the current total number of issued tokensblockNumber
, blockTimestamp
, and transactionHash
are the block data that is not related to the protocol but useful for data analysissrc/friendtech-shares-v-1.ts
which contains the straightforward AssemblyScript code transferring the smart contract events data into the tables with the described structure.
handleTrade
function is what we are interested in. We see that each event emitting leads to the new entity created with the fields that exactly correspond to the table structure without any changes. But if you need any additional operations you can add them in the function.
Finally, to start using the subgraph, run the command: