Skip to content

yirenlu92/fuels-ts

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fuels-ts SDK logo

fuels-ts is a library for interacting with Fuel v2.

Table of contents

Features

  • Deploy and call contracts
  • Generate contract types with TypeChain
  • Build and send transactions
  • Encode/decode contract ABI
  • Transfer coins
  • Inspect contract storage
  • Manage wallets
  • Run scripts
  • Query and subscribe to events

Usage

Installation

yarn add fuels
# or
npm add fuels

Calling Contracts

import { Provider, Contract } from "fuels";
import abi from "./abi.json";

const provider = new Provider("http://127.0.0.1:4000/graphql");

const contractId = "0x...";
const contract = new Contract(contractId, abi, provider);
const result = await contract.functions.foo("bar");

Deploying Contracts

import { Provider, Contract } from "fuels";
import bytecode from "./bytecode.bin";

const provider = new Provider("http://127.0.0.1:4000/graphql");

const { contractId } = await provider.submitContract(bytecode);

Generating Contract Types

yarn add -D typechain typechain-target-fuels
yarn exec typechain --target=fuels --out-dir=types abi.json
import { Provider } from "fuels";
import { MyContract__factory } from "./types";

const provider = new Provider("http://127.0.0.1:4000/graphql");

const contractId = "0x...";
const contract = MyContract__factory.connect(contractId, provider);

Contributing

Setup

git clone [email protected]:FuelLabs/fuels-ts.git
cd fuels-ts
npm install

Testing

# run all tests
npm run test
# run tests and get coverage
npm run test:coverage
# run tests for a specific package
npm -w @fuel-ts/contract run test

License

The primary license for this repo is Apache 2.0, see LICENSE.

About

Fuel v2 TypeScript SDK

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 99.2%
  • Other 0.8%