From a4091b4bfb03bede1fb6658e61b9bf9094fd6e55 Mon Sep 17 00:00:00 2001 From: shiyasmohd Date: Mon, 22 Apr 2024 16:45:47 +0530 Subject: [PATCH 1/2] docs: added getBalance() in ethereum API section --- website/pages/en/developing/graph-ts/api.mdx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/website/pages/en/developing/graph-ts/api.mdx b/website/pages/en/developing/graph-ts/api.mdx index fe09ac9f68b1..8b1631147b26 100644 --- a/website/pages/en/developing/graph-ts/api.mdx +++ b/website/pages/en/developing/graph-ts/api.mdx @@ -536,6 +536,17 @@ For more information: - Encoding/decoding [Rust library/CLI](https://github.com/rust-ethereum/ethabi) - More [complex example](https://github.com/graphprotocol/graph-node/blob/6a7806cc465949ebb9e5b8269eeb763857797efc/tests/integration-tests/host-exports/src/mapping.ts#L72). +#### Balance of an Address + +The balance of an address can be retrieved using the `ethereum` module. This feature is available from `apiVersion: 0.0.9` defined `subgraph.yaml`. The `getBalance()` retrieves the balance of the specified address from the block currently being processed within the subgraph. + +```typescript +import { ethereum } from '@graphprotocol/graph-ts' + +let address = Address.fromString('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045') +let balance = ethereum.getBalance(address) // returns balance in BigInt +``` + ### Logging API ```typescript From 6ba521830da1998681b779d814cd7b0bff86ad0e Mon Sep 17 00:00:00 2001 From: shiyasmohd Date: Mon, 22 Apr 2024 16:47:51 +0530 Subject: [PATCH 2/2] fix: updated graph-ts library link to graph-tooling --- website/pages/en/developing/graph-ts/api.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/pages/en/developing/graph-ts/api.mdx b/website/pages/en/developing/graph-ts/api.mdx index 8b1631147b26..a03c22f0004c 100644 --- a/website/pages/en/developing/graph-ts/api.mdx +++ b/website/pages/en/developing/graph-ts/api.mdx @@ -6,7 +6,7 @@ title: AssemblyScript API This page documents what built-in APIs can be used when writing subgraph mappings. Two kinds of APIs are available out of the box: -- the [Graph TypeScript library](https://github.com/graphprotocol/graph-ts) (`graph-ts`) and +- the [Graph TypeScript library](https://github.com/graphprotocol/graph-tooling) (`graph-ts`) and - code generated from subgraph files by `graph codegen`. It is also possible to add other libraries as dependencies, as long as they are compatible with [AssemblyScript](https://github.com/AssemblyScript/assemblyscript). Since this is the language mappings are written in, the [AssemblyScript wiki](https://github.com/AssemblyScript/assemblyscript/wiki) is a good source for language and standard library features.