Skip to content

Commit

Permalink
Minor bugfix for Go code
Browse files Browse the repository at this point in the history
  • Loading branch information
dineshpinto committed Jun 6, 2024
1 parent e977ad4 commit d9c3ebf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
4 changes: 3 additions & 1 deletion code_examples/developer-hub-go/ftsov2_consumer_coston.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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)
Expand Down
44 changes: 22 additions & 22 deletions docs/ftso/guides/read-feeds-offchain.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ This example shows two ways, one using [web3.js](https://github.com/web3/web3.js
}

main();

```

</TabItem>
Expand Down Expand Up @@ -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)
}
```

0 comments on commit d9c3ebf

Please sign in to comment.