Version
This doc was generated using Fuels v0.79.0
, Fuel Core v0.22.1
, Sway v0.49.3
, and Forc v0.49.3
.
Installation Guide
Please visit the Fuel's installation guide to install The Fuel toolchain binaries and pre requisites.
Developer Quickstart Guide
We recommend starting with the Developer Quickstart for a walk through on building your first DApp on Fuel.
The Fuel Ecosystem
Learn more about the Fuel Ecosystem.
- 🌴 Sway the new language. Empowering everyone to build reliable and efficient smart contracts.
- 🧰 Forc the Fuel toolbox. Build, deploy and manage your sway projects.
- ⚙️ Fuel Core the new FuelVM, a blazingly fast blockchain VM.
- 🔗 Fuel Specs the Fuel protocol specifications.
- 🦀 RUST SDK a robust SDK in rust.
- ⚡ Fuel Network the project.
Install
sh
pnpm add fuels
sh
npm install fuels --save
If you are a Windows user, you will need to be running Windows Subsystem for Linux (WSL) to install and use the Fuel toolchain, including the TypeScript SDK. We don't support Windows natively at this time.
Import
ts
import { Wallet } from "fuels";
// Random Wallet
console.log(Wallet.generate());
// Using privateKey Wallet
console.log(Wallet.fromPrivateKey(PRIVATE_KEY));
Calling Contracts
ts
import { Provider, Wallet, Contract, BigNumberish, BN } from "fuels";
import abi from "./abi.json";
const provider = await Provider.create('https://beta-5.fuel.network/graphql');
const wallet = Wallet.fromPrivateKey(PRIVATE_KEY, provider); // private key with coins
const contractId = "0x...";
const contract = new Contract(contractId, abi, wallet);
// All contract methods are available under functions
const { transactionId, value } = await contract.functions
.foo<[BigNumberish], BN>("bar")
.call();
console.log(transactionId, value);
Deploying Contracts
ts
import { Provider, ContractFactory } from "fuels";
// Byte code generated using: forc build
import bytecode from "./bytecode.bin";
const factory = new ContractFactory(bytecode, [], wallet);
const contract = await factory.deployContract();
console.log(contract.id);
License
The primary license for this repo is Apache 2.0
, see LICENSE
.