Fuel and V12 Market Setup Tutorial

Step 1: Install the Fuel Toolchain

First, install the Fuel toolchain by following the instructions provided in the Fuel documentation:

Install the Fuel Toolchain

Step 2: Install the V12 Rust Packages

Next, create a new directory for your project and initialize a new Rust package using cargo init. You’ll also need to install the necessary V12 and environment packages by running the following commands:

cargo init
cargo add tokio
cargo add env
cargo add dotenv
cargo add fuels
cargo add spark-market-sdk
cargo add spark-registry-sdk

Step 3: Set Up Your `.env` File

Create a .env file in the root of your project and add the following environment variables:

# Mnemonic phrase 
MNEMONIC="your mnemonic here"

# Spark Contracts
MARKET_REGISTRY="0x194987ad2314d2de50646078ac1841f00b2dffda863a7d3dd421d220eb83d019"
BTC_USDC_CONTRACT_ID="0x7b88385ae73dd3ccc62012e7a52cddd05c7e82ad54a5df721dfa0c1f8b5998f0"
ETH_USDC_CONTRACT_ID="0xc18094a283193c9b4726d2f644ed07ec9806bbe60a0688d45bffb26c379c1428"

# Asset IDs
BTC_ID="0x38e4ca985b22625fff93205e997bfc5cc8453a953da638ad297ca60a9f2600bc"
ETH_ID="0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
USDC_ID="0x336b7c06352a4b736ff6f688ba6885788b3df16e136e95310ade51aa32dc6f05"

Note: Be sure to check for the latest contract deployment addresses here.

Step 4: Call the Spark Market Contract

Now, let’s call the Spark Market contract to retrieve the matcher and protocol fees. Here's an example code to achieve that:

Additional Resources

Last updated