Skip to content

Version

This doc was generated using Fuels v0.44.1, Fuel Core v0.17.3, Sway v0.35.5, and Forc v0.35.5.

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.

Install

YARN

sh
yarn add fuels

NPM

sh
npm install fuels --save

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 { Wallet, Contract, BigNumberish, BN } from "fuels";
import abi from "./abi.json";

const wallet = Wallet.fromPrivateKey(PRIVATE_KEY); // 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);

READ MORE

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.