Giter Site home page Giter Site logo

luizstacio / fuels-ts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fuellabs/fuels-ts

1.0 1.0 0.0 4.65 MB

Fuel v2 TypeScript SDK

Home Page: https://fuellabs.github.io/fuels-ts

License: Apache License 2.0

Shell 0.35% JavaScript 0.65% TypeScript 98.84% Makefile 0.04% Dockerfile 0.12%

fuels-ts's Introduction

Fuels-ts SDK logo

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

test npm docs discord

Table of contents

Quickstart

We recommend to start on Quickstart to speed-up and build your first DApp using Fuel.

Documentation

Find more information about packages in our Documentation.

The Fuel Ecosystem

Learn more about the Fuel Ecosystem.

Install

YARN

yarn add fuels

NPM

npm install fuels --save

Import

import { Wallet } from "fuels";

// Random Wallet
console.log(Wallet.generate());

// Using privateKey Wallet
console.log(new Wallet("0x0000...0000"));

Calling Contracts

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

const wallet = new Wallet("0x..."); // private key with coins
const contractId = "0x...";
const contract = new Contract(contractId, abi, wallet);

// All contract methods are available under functions
// with the correct types
const { transactionId, value } = await contract.functions
  .foo<[string], bigint>("bar")
  .call();

console.log(transactionId, value);

READ MORE

Generate Contract Types from ABI

Dependencies

yarn add -D typechain typechain-target-fuels

Generate Types

yarn exec typechain --target=fuels --out-dir=types abi.json

Using Generated Types

import { Wallet } from "fuels";
import { MyContract__factory } from "./types";

const contractId = "0x...";
const wallet = new Wallet("0x...");
const contract = MyContract__factory.connect(contractId, wallet);

// All contract methods are available under functions
// with the correct types
const { transactionId, value } = await contract.functions.my_fn(1n).call();
console.log(transactionId, value);

Deploying Contracts

import { Provider, Contract } from "fuels";
// Byte code generated using: forc build
import bytecode from "./bytecode.bin";

const factory = new ContractFactory(bytecode, [], wallet);
const contract = await factory.deployContract(factory);

console.log(contract.id);

License

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

fuels-ts's People

Contributors

adlerjohn avatar alicanc avatar biantris avatar camiinthisthang avatar camsjams avatar github-actions[bot] avatar joshuabatty avatar luizasfight avatar luizstacio avatar pedronauck avatar quinnlee avatar sdankel avatar yirenlu92 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.