Git Product home page Git Product logo

fuel-msg-sender's Introduction

Sending a message from Fuel to ETH

  1. Modify main.sw with the desired recipient and message data
  2. Run forc build
  3. Run npm run send -- <SIGNING_KEY> where the key is the private key with proper funds on Fuel.

Anotate the output 's MessageOut, you will need it later

Example sent message:

[
  {
    "MessageOut": {
      "amount": 0,
      "data": [
        97, 103, 103, 114, 101, 103, 97, 116, 101, 82, 111, 111, 116, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
      ],
      "digest": "3503cc2708f3f91c16e00dfcb4cad647e7d7a98a332e324339b53ffcd6133901",
      "len": 32,
      "nonce": "52a2d864323716ccda6c9c660ffd6e128f4e8f4159949b4aa9bf8bacdf0c3f82",
      "recipient": "0000000000000000000000008d8bb34fb9a1a52ac0bddc9901c5c7b5e7347d05",
      "sender": "1dea0b3859c120208de2322822f65b186618c005c7aa0994cb77f85269b4e680"
    }
  },
  {
    "Return": {
      "id": "0000000000000000000000000000000000000000000000000000000000000000",
      "is": 10344,
      "pc": 10628,
      "val": 0
    }
  },
  { "ScriptResult": { "gas_used": 258, "result": "Success" } }
]

Relaying the sent message in ETH network

Replace:

export const MESSAGE_OUT = {
  amount: bn(0),
  data: [
    79, 247, 70, 246, 97, 103, 103, 114, 101, 103, 97, 116, 101, 82, 111, 111,
    116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  ],
  digest: "a6d7e646102900dcbc590015d4688801cb29528e07ced88428606519f701a04e",
  len: 36,
  nonce: "6e73dbd15aba133ee97b8fb33e0b996e1768ddbf4f66d306c5e788747d7f9548",
  recipient: "0000000000000000000000008d8bb34fb9a1a52ac0bddc9901c5c7b5e7347d05",
  sender: "128573a29021c87688cd5cff01f2247400c210741b563c9ad8140009dea2b620",
};

With your own message that you have noted on the first step. Then run:

  • npx hardhat run scripts/simulate_relay.ts to do a static call and check that the message can be correctly relayed
  • ETH_PRIVATE_KEY="PRIVATE_KEY" npx hardhat run scripts/relay.ts (or configure it via .env) to actually send the transaction and relay the message

fuel-msg-sender's People

Contributors

deficake 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.