Git Product home page Git Product logo

Comments (1)

SilentCicero avatar SilentCicero commented on June 26, 2024

@stskeeps this feature is on the way #12 and will become available in @fuel-js/[email protected]. We can experiment a bit with API's but this is the general format.

// Get the transaction Id for this transfer.
const txTokenId = 1;
const txAddress = '0x1dF62f291b2E969fB0849d99D9Ce41e2F137006e';
const txAmount = utils.parseEther('1');

// Generate the transactionId for this transfer.
const transactionId = await wallet.transfer(txTokenId, txAddress, txAmount, {
    transactionId: true,
});

// Commit the witness, note the contract object can be used by any provider (web3/ethers)
// it just has to contact the `fuel` contract directly and use the `commitWitness(bytes32 transactionId)` ABI.
let commitTx = await wallet.contract.commitWitness(transactionId, {
    gasLimit: 200000,
});

// Here we wait for the transaction to process, but I also increased the number of blocks to let the Fuel aggregator pickup the log.
// We will likely want to add a checking step here (on a loop) to ensure the Fuel sequencer has picked up the witness commitment.
// For now just attempt to do the transfer until it goes through, but wait a few blocks to ensure the sequencer can pick it up, I selected 12 Ethereum blocks here, in ethers.js notation below.
commitTx = await commitTx.wait(12);

// Transfer using Caller witness.
await wallet.transfer(txTokenId, txAddress, txAmount, {
    // Here we provide the necessary event data to build the Caller witness (i.e. `{ blockNumber, address }`)
    caller: commitTx.events[0].args,
});

Anyway, should be in once the PR is reviewed / merged.

from fuel-js.

Related Issues (16)

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.