Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: read-offchain-feeds guide links, dev hub links, go generate etc. #84

Merged
merged 6 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/1-intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ keywords:
import ThemedImage from "@theme/ThemedImage";
import useBaseUrl from "@docusaurus/useBaseUrl";

**Flare is the blockchain for data**, providing developers and users with secure, decentralized access to high-integrity data from other chains and the internet. As an EVM-compatible Layer-1 blockchain, complete with enshrined data protocols, Flare offers a full-stack solution for building the next generation of secure, interoperable, and data-driven decentralized applications.
**Flare is the blockchain for data**, offering developers and users secure, decentralized access to high-integrity data from other chains and the internet. Flare's Layer-1 network uniquely supports enshrined data protocols at the network layer, making it the only EVM-compatible smart contract platform optimized for decentralized data acquisition, including price and time-series data, blockchain event and state data, and Web2 API data.

By providing broad data access at scale and minimal cost, Flare delivers a full-stack solution for building the next generation of secure, interoperable, and data-driven decentralized applications.

## Getting started

- [Deploy your first smart contract](/network/getting-started) — Build and deploy your first on-chain Flare smart contract, using only your browser.
- [Deploy your first smart contract](/network/getting-started) — Build and deploy your first smart contract on Flare, using only your browser.

- [Learn how to use FTSOv2](./ftso/overview) — Leverage the latest upgrades to the Flare Time Series Oracle, with feeds now updating every ≈1.8 seconds.
- [Learn how to use FTSOv2](./ftso/overview) — Leverage the latest upgrades to the Flare Time Series Oracle (FTSO), with feeds now updating every ≈1.8 seconds.

- Start building on Flare with programming languages you may already know

Expand All @@ -34,9 +36,7 @@ import useBaseUrl from "@docusaurus/useBaseUrl";

## Understand the architecture

Build a strong understanding of the core concepts that set Flare apart from other blockchains:

- Flare's data protocols, [Flare Time Series Oracle (FTSO)](./ftso/overview) and [Flare Data Connector (FDC)](./fdc/overview), are enshrined into the core protocol of Flare, and inherit the economic security of the entire network.
Build a strong understanding of the core concepts that set Flare apart from other blockchains. Flare's data protocols, [Flare Time Series Oracle (FTSO)](./ftso/overview) and [Flare Data Connector (FDC)](./fdc/overview), are enshrined into the core protocol of Flare, and inherit the economic security of the entire network.

<ThemedImage
alt="Flare Architecture"
Expand All @@ -50,6 +50,6 @@ Build a strong understanding of the core concepts that set Flare apart from othe

- [Contribute to Flare's open-source codebase](https://github.com/flare-foundation) — Help build the future of Flare.

- [Become a data provider](./run-a-node/ftso-data-provider) — Support DeFi applications on Flare with high-integrity, block-latency data feeds.
- [Become an FTSO data provider](./run-a-node/ftso-data-provider) — Support DeFi applications on Flare with high-integrity, block-latency data feeds.

- [Run a Flare validator](./run-a-node/validator-node) — Secure Flare and earn rewards by running a validator node.
10 changes: 5 additions & 5 deletions docs/ftso/guides/read-feeds-offchain.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ sidebar_position: 2
import TabItem from "@theme/TabItem";
import Tabs from "@theme/Tabs";
import CodeBlock from "@theme/CodeBlock";
import ReadOffhainEthersJs from "!!raw-loader!/examples/developer-hub-javascript/ftsov2_config_coston2_ethers.js";
import ReadOffhainWeb3Js from "!!raw-loader!/examples/developer-hub-javascript/ftsov2_config_coston2_web3.js";
import ReadOffhainWeb3Py from "!!raw-loader!/examples/developer-hub-python/ftsov2_config_coston2.py";
import ReadOffhainRust from "!!raw-loader!/examples/developer-hub-rust/src/bin/ftsov2_config_coston2.rs";
import ReadOffhainGo from "!!raw-loader!/examples/developer-hub-go/ftsov2_config_coston2.go";
import ReadOffhainEthersJs from "!!raw-loader!/examples/developer-hub-javascript/ftsov2_consumer_coston2_ethers.js";
import ReadOffhainWeb3Js from "!!raw-loader!/examples/developer-hub-javascript/ftsov2_consumer_coston2_web3.js";
import ReadOffhainWeb3Py from "!!raw-loader!/examples/developer-hub-python/ftsov2_consumer_coston2.py";
import ReadOffhainRust from "!!raw-loader!/examples/developer-hub-rust/src/bin/ftsov2_consumer_coston2.rs";
import ReadOffhainGo from "!!raw-loader!/examples/developer-hub-go/ftsov2_consumer_coston2.go";

This guide provides code examples demonstrating how to read FTSOv2 feeds off-chain using various programming languages. To read a block-latency feed off-chain, you need three key pieces of information:

Expand Down
17 changes: 14 additions & 3 deletions docs/network/guides/flare-secure-rng.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
---
slug: random-number-generation
title: Flare's Secure RNG
tags: [quickstart, solidity]
tags: [quickstart, solidity, javascript, python, rust, go]
authors: [dineshpinto, horiamagureanu, charlesgrover]
description: Use Flare's secure random number generator.
keywords: [solidity, randomness, random-number, smart-contract, flare-network]
keywords:
[
solidity,
javascript,
python,
rust,
go,
randomness,
randomn-number,
flare-time-series-oracle,
flare-network,
]
sidebar_position: 6
---

Expand All @@ -22,7 +33,7 @@ import SecureRandomGo from "!!raw-loader!/examples/developer-hub-go/coston2/secu

This guide demonstrates how to obtain cryptographically secure random numbers on Flare. The randomness is generated from FTSOv2's [Scaling](/ftso/scaling/overview) protocol, which consists of a decentralized network of around 100 data providers that generate random numbers every 90 seconds.

You can integrate this secure randomness into your decentralized application for no cost (other than gas).
You can integrate this secure randomness into your on-chain application for no cost (other than gas).

<details>
<summary>**Understand the mechanism behind Flare's Secure RNG.**</summary>
Expand Down
1 change: 1 addition & 0 deletions examples/developer-hub-go/coston2/secure_random.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

func SecureRandom() {
// Relay address (Flare Testnet Coston2)
// See https://dev.flare.network/ftso/scaling/solidity-reference
address := common.HexToAddress("0x5CdF9eAF3EB8b44fB696984a1420B56A7575D250")
rpcUrl := "https://rpc.ankr.com/flare_coston2"
// Connect to an RPC node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func MakeVolatilityIncentive() {
// Get private key from environment
privateKey, _ := crypto.HexToECDSA(os.Getenv("ACCOUNT_PRIVATE_KEY")[2:])
// FastUpdatesIncentiveManager address (Flare Testnet Coston2)
// See https://dev.flare.network/ftso/solidity-reference
incentiveAddress := common.HexToAddress("0x003e9bD18f73e0B25BED0DC8382Bde6aa999525c")
// Connect to an RPC node
client, _ := ethclient.Dial("https://rpc.ankr.com/flare_coston2")
Expand Down
1 change: 1 addition & 0 deletions examples/developer-hub-go/ftsov2_config_coston2.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

func FtsoV2Config() {
// FastUpdatesConfiguration address (Flare Testnet Coston2)
// See https://dev.flare.network/ftso/solidity-reference
address := common.HexToAddress("0xE7d1D5D58cAE01a82b84989A931999Cb34A86B14")
rpcUrl := "https://rpc.ankr.com/flare_coston2"
// Connect to an RPC node
Expand Down
1 change: 1 addition & 0 deletions examples/developer-hub-go/ftsov2_consumer_coston2.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

func FtsoV2Consumer() {
// FastUpdater address (Flare Testnet Coston2)
// See https://dev.flare.network/ftso/solidity-reference
ftsoAddress := common.HexToAddress("0x58fb598EC6DB6901aA6F26a9A2087E9274128E59")
rpcUrl := "https://rpc.ankr.com/flare_coston2"
// Connect to an RPC node
Expand Down
6 changes: 5 additions & 1 deletion examples/developer-hub-go/main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package main

// coston2 package ABIs
//go:generate abigen --abi Relay.abi --pkg coston2 --type Relay --out coston2/Relay.go
//go:generate abigen --abi FlareContractRegistry.abi --pkg coston2 --type FlareContractRegistry --out coston2/FlareContractRegistry.go
//go:generate abigen --abi=build/FtsoV2FeedConsumer.abi --pkg coston2 --type FtsoV2FeedConsumer --out coston2/FtsoV2FeedConsumer.go
//go:generate abigen --bin=build/FtsoV2FeedConsumer.bin --abi=build/FtsoV2FeedConsumer.abi --pkg coston2 --type FtsoV2FeedConsumer --out coston2/FtsoV2FeedConsumer.go
//go:generate abigen --abi FastUpdatesIncentiveManager.abi --pkg coston2 --type FastUpdatesIncentiveManager --out coston2/FastUpdatesIncentiveManager.go
//go:generate abigen --abi FastUpdatesConfiguration.abi --pkg main --type FastUpdatesConfiguration --out FastUpdatesConfiguration.go
//go:generate abigen --abi FastUpdater.abi --pkg main --type FastUpdater --out FastUpdater.go
// flare package ABIs
//go:generate abigen --abi FlareContractRegistry.abi --pkg flare --type FlareContractRegistry --out flare/FlareContractRegistry.go
//go:generate abigen --bin=build/FtsoV2FeedConsumer.bin --abi=build/FtsoV2FeedConsumer.abi --pkg flare --type FtsoV2FeedConsumer --out flare/FtsoV2FeedConsumer.go

import (
"developer-hub-go/coston2"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/developer-hub-python/ftsov2_config_coston2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from web3 import AsyncHTTPProvider, AsyncWeb3

# FastUpdatesConfiguration address (Flare Testnet Coston2)
# See https://dev.flare.network/ftso/solidity-reference
ADDRESS = "0xE7d1D5D58cAE01a82b84989A931999Cb34A86B14"
RPC_URL = "https://rpc.ankr.com/flare_coston2"
# ABI for FastUpdatesConfiguration contract
Expand Down
1 change: 1 addition & 0 deletions examples/developer-hub-python/ftsov2_consumer_coston2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from web3 import AsyncHTTPProvider, AsyncWeb3

# FastUpdater address (Flare Testnet Coston2)
# See https://dev.flare.network/ftso/solidity-reference
FTSO_ADDRESS = "0x58fb598EC6DB6901aA6F26a9A2087E9274128E59"
RPC_URL = "https://rpc.ankr.com/flare_coston2"
# Feed indexes: 0 = FLR/USD, 2 = BTC/USD, 9 = ETH/USD
Expand Down
1 change: 1 addition & 0 deletions examples/developer-hub-python/secure_random_coston2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from web3 import AsyncHTTPProvider, AsyncWeb3

# Relay address (Flare Testnet Coston2)
# See https://dev.flare.network/ftso/scaling/solidity-reference
ADDRESS = "0x5CdF9eAF3EB8b44fB696984a1420B56A7575D250"
RPC_URL = "https://rpc.ankr.com/flare_coston2"
# ABI for Relay contract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


# FastUpdatesIncentiveManager address (Flare Testnet Coston2)
# See https://dev.flare.network/ftso/solidity-reference
INCENTIVE_ADDRESS = "0x003e9bD18f73e0B25BED0DC8382Bde6aa999525c"
RPC_URL = "https://rpc.ankr.com/flare_coston2"
# ABI for FastUpdatesIncentiveManager contract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ sol!(
#[tokio::main]
async fn main() -> Result<()> {
// FastUpdatesConfiguration address (Flare Testnet Coston2)
// See https://dev.flare.network/ftso/solidity-reference
let address = "0xE7d1D5D58cAE01a82b84989A931999Cb34A86B14".parse()?;
let rpc_url = "https://rpc.ankr.com/flare_coston2".parse()?;
// Connect to an RPC node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ sol!(
#[tokio::main]
async fn main() -> Result<()> {
// FastUpdater address (Flare Testnet Coston2)
// See https://dev.flare.network/ftso/solidity-reference
let ftso_address = "0x58fb598EC6DB6901aA6F26a9A2087E9274128E59".parse()?;
let rpc_url = "https://rpc.ankr.com/flare_coston2".parse()?;
// Feed indexes: 0 = FLR/USD, 2 = BTC/USD, 9 = ETH/USD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ sol!(

#[tokio::main]
async fn main() -> Result<()> {
// Relay address (Flare Testnet Coston2)
// Relay address (Flare Testnet Coston2)
// See https://dev.flare.network/ftso/scaling/solidity-reference
let relay_address = "0x5CdF9eAF3EB8b44fB696984a1420B56A7575D250".parse()?;
let rpc_url = "https://rpc.ankr.com/flare_coston2".parse()?;
// Connect to an RPC node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ async fn main() -> Result<()> {
// Get private key from environment
let private_key = std::env::var("ACCOUNT_PRIVATE_KEY")?;
// FastUpdatesIncentiveManager address (Flare Testnet Coston2)
let ftso_address = "0x003e9bD18f73e0B25BED0DC8382Bde6aa999525c".parse()?;
// See https://dev.flare.network/ftso/solidity-reference
let incentive_address = "0x003e9bD18f73e0B25BED0DC8382Bde6aa999525c".parse()?;
// Set up wallet and provider
let signer: PrivateKeySigner = private_key.parse().unwrap();
let wallet = EthereumWallet::from(signer.clone());
Expand All @@ -25,7 +26,7 @@ async fn main() -> Result<()> {
.wallet(wallet)
.on_http("https://rpc.ankr.com/flare_coston2".parse()?);
// Set up contract instance
let incentive = FastUpdatesIncentiveManager::new(ftso_address, provider);
let incentive = FastUpdatesIncentiveManager::new(incentive_address, provider);

// Get the current sample size, sample size increase price, range, and scale
let FastUpdatesIncentiveManager::getCurrentSampleSizeIncreasePriceReturn {
Expand Down
Loading