Video walkthrough
Getting the ABI
Contract ABI
section.Creating the configuration file
friendtech-config.json
). This file consists of five key sections:friendtech
.ftshares
and abi.json
.instances
should match a key in abis
, in this example,
ftshares
. It is possible to have more than one chains
and more than one
ABI. Multiple chains will result in multiple subgraphs. The file abi.json
in
this example should contain the friendtech ABI downloaded from
here.Deploying the subgraph
goldsky login
.goldsky subgraph deploy name/version --from-abi <path-to-config-file>
, then pass in the path to the config file you created. Note - do NOT pass in the ABI itself, but rather the config file defined above. Example: goldsky subgraph deploy friendtech/1.0 --from-abi friendtech-config.json
@graphprotocol/graph-ts
beyond BigInt
, Bytes
, and store
can be declared in the options.imports
field of the enrichment (e.g., BigDecimal
).required
or having another call declare them as a depends_on
dependency will abort if the call is not successful, otherwise the call output value will remain as null
.declared
will configure the subgraph to execute the call prior to invoking the mapping handler. This can be useful for performance reasons, but only works for eth calls that have no mapping handler dependencies.pre
and post
expressions for conditions
to test before and after the call, if either fails the call is aborted. Since these are expressions, they can be dynamic or constant values.source
is an expression and therefore allows for dynamic values using math or concatenations. If the source
is simply a contract address then it will be automatically converted to an Address
type.params
is an expression list and can also be dynamic values or constants.id
expression to be defined for each entity, id
can by a dynamic value or a constant. this id
is appended to the parent entity id
to create a unique id
for each enrichment entity in the list.explicit_id
flag to true
, this will use the value of id
without appending it to the parent entity id
, creating an addressable entity that can be updated.enrich
section of the configuration, and in most cases only the part of the enrich
section that is relevant. See the enrichments configuration reference for the full configuration reference.
BigDecimal
for use in a calls
or entities
section.
abi
and source
configuration fields, as they are implied in this scenario, we only need to include the name
and params
fields (if the function declares paramters). We can refer to the result of this call using calls.balance
.
calls.owner
meaning we need the value of the owner
call before we can invoke balanceOf
). This means that if the first call fails, the second call will not be executed. Calls are always executed in the order they are configured, so the second call will have access to the output of the first call (in this example, we use that output as a parameter to the second call). We can list multiple calls in the depends_on
array to create a dependency graph (if needed). Adding a call to the depends_on
array will not automatically re-order the calls, so be sure to list them in the correct order.
abi
and source
configuration fields.
contractAddress
function is returning an Address
type so we can use the call result directly in the source
field of the second call. If contractAddress
was instead returning a string
type, then we would use "source": "Address.fromString(calls.contract_address)"
, though this would be an unusual case to observe.
depends_on
, the dependency call is automatically marked as required. This should be used when the address of the contract being called may not always implement the function being called.
true
becomes !(true)
, which is always false and therefore never aborts). In this example, we’re excluding the call if the owner
is in a deny list, and we’re aborting the enrichment if the balance is 0
.
id
field from the event params into our enrichment entity. This can be useful if you want to filter or sort the enrichment entities by this field.
String
vs Address
).
usd_balance
on whether or not the usdc_balance
call was successful. If the call was not successful, then we set the value to BigDecimal.zero()
, otherwise we divide the call result by 10^6
(USDC decimals) to convert the balance to a USD
value.
id
value.
explicit_id
flag.subgraph.json
) and deployed using goldsky subgraph deploy nouns/1.0.0 --from-abi subgraph.json
.
balance
field to a Balance
enrichment entity. This balance
field is populated by calling the balanceOf
function on the to
address of the Transfer
event.
balance
field on both FromBalance
and ToBalance
enrichment entities. This balance
field is populated by calling the balanceOf
function on both the from
and to
address of the Transfer
event.
Balance
entity, so that both sender and receiver use the same entity.
Balance
entity by the owner address (id
) to see the current balance.declared
flag to boost performance of the balanceOf
eth calls. declared calls only work for eth calls that have no mapping handler dependencies, in other words the call can be executed from the event params only. Also note that call handlers do not support delcared calls (yet), if declared
is set on a call handler enrichment it will be ignored.