diff --git a/code_examples/developer-hub-go/ftsov2_consumer_coston.go b/code_examples/developer-hub-go/ftsov2_consumer_coston.go index a39780fa..396fe83a 100644 --- a/code_examples/developer-hub-go/ftsov2_consumer_coston.go +++ b/code_examples/developer-hub-go/ftsov2_consumer_coston.go @@ -5,10 +5,11 @@ import ( "context" "fmt" + "math/big" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" - "math/big" ) func FtsoV2Consumer() { @@ -24,6 +25,7 @@ func FtsoV2Consumer() { // Fetch current feeds opts := &bind.CallOpts{Context: context.Background()} res, _ := ftsov2.FetchCurrentFeeds(opts, feedIndexes) + // Print results fmt.Println("Feeds:", res.Feeds) fmt.Println("Decimals:", res.Decimals) fmt.Println("Timestamp:", res.Timestamp) diff --git a/docs/ftso/guides/read-feeds-offchain.mdx b/docs/ftso/guides/read-feeds-offchain.mdx index 212814ad..8ae3a8f0 100644 --- a/docs/ftso/guides/read-feeds-offchain.mdx +++ b/docs/ftso/guides/read-feeds-offchain.mdx @@ -148,7 +148,6 @@ This example shows two ways, one using [web3.js](https://github.com/web3/web3.js } main(); - ``` @@ -219,30 +218,31 @@ abigen --abi FastUpdater.abi --pkg main --type FastUpdater --out FastUpdater.go package main import ( - "context" - "fmt" + "context" + "fmt" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" - "math/big" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/ethclient" + "math/big" ) func FtsoV2Consumer() { - // FastUpdater address (Songbird Testnet Coston) - address := common.HexToAddress("0x9B931f5d3e24fc8C9064DB35bDc8FB4bE0E862f9") - rpcUrl := "https://rpc.ankr.com/flare_coston" - // Connect to an RPC node - client, _ := ethclient.Dial(rpcUrl) - // Set up contract instance - ftsov2, _ := NewFastUpdater(address, client) - // Feed indexes: 0 = FLR/USD, 2 = BTC/USD, 9 = ETH/USD - feedIndexes := []*big.Int{big.NewInt(0), big.NewInt(2), big.NewInt(9)} - // Fetch current feeds - opts := &bind.CallOpts{Context: context.Background()} - res, _ := ftsov2.FetchCurrentFeeds(opts, feedIndexes) - fmt.Println("Feeds:", res.Feeds) - fmt.Println("Decimals:", res.Decimals) - fmt.Println("Timestamp:", res.Timestamp) + // FastUpdater address (Songbird Testnet Coston) + address := common.HexToAddress("0x9B931f5d3e24fc8C9064DB35bDc8FB4bE0E862f9") + rpcUrl := "https://rpc.ankr.com/flare_coston" + // Connect to an RPC node + client, _ := ethclient.Dial(rpcUrl) + // Set up contract instance + ftsov2, _ := NewFastUpdater(address, client) + // Feed indexes: 0 = FLR/USD, 2 = BTC/USD, 9 = ETH/USD + feedIndexes := []*big.Int{big.NewInt(0), big.NewInt(2), big.NewInt(9)} + // Fetch current feeds + opts := &bind.CallOpts{Context: context.Background()} + res, _ := ftsov2.FetchCurrentFeeds(opts, feedIndexes) + // Print results + fmt.Println("Feeds:", res.Feeds) + fmt.Println("Decimals:", res.Decimals) + fmt.Println("Timestamp:", res.Timestamp) } ```