Giter Club home page Giter Club logo

Comments (5)

cgcardona avatar cgcardona commented on July 4, 2024 2

You can sign a message w/ a key and then take the resulting signature and recover the address from the message and signature.

Check out this gist

ts-node sign-message-and-recover-address.ts
Address: X-local18jma8ppw3nhx5r4ap8clazz0dps7rv5u00z96u
Message: From snowflake to Avalanche
Signature: Df5bvmWnqRYSpWBbJX3KNPnKNgWhoefSjQ6ZbB7hNiH8xzmJcssaeEFwotwfwC8FvriJUfueHfULXdouFq9sAbFwmJ1S5U
--------------------------
Recovering address from message and signature...
Address: X-local18jma8ppw3nhx5r4ap8clazz0dps7rv5u00z96u

You should be able to do something similar where the serialized transaction is the message.

from avalanchejs.

farukterzioglu avatar farukterzioglu commented on July 4, 2024 1

This doesn't solve my problem. I don't have the message nor the signature, so I can't recover the public key (so the address)

Message that signed is the transaction which input refers to. If I send another query just to get the previous tx (message that signed) I can also get address from outputs. No point for address recovery.

I am looking for a way to use Avalanchejs for this.
As I understand Avalanche transactions doesn't have public key info in inputs, so no possibility to get address from inputs (w/o sending another query to the node)

from avalanchejs.

cgcardona avatar cgcardona commented on July 4, 2024

Reopening

from avalanchejs.

cgcardona avatar cgcardona commented on July 4, 2024

GetTxByID isn't a method on AvalancheJS. Can you provide any more details? I'm guessing you mean getTx.

@farukterzioglu can you provide a gist of what you're doing?

from avalanchejs.

paOol avatar paOol commented on July 4, 2024

while you have the UnsignedTx object,

you can serialize it to find a breakdown of the transaction

let serialized: any = unsignedTx.serialize("display")
console.log(JSON.stringify(serialized))

you would get something that looks like the following.

{
  "_typeName": "Tx",
  "_typeID": null,
  "_codecID": null,
  "unsignedTx": {
    "_typeName": "UnsignedTx",
    "_typeID": null,
    "_codecID": null,
    "codecID": "0",
    "transaction": {
      "_typeName": "ExportTx",
      "_typeID": 4,
      "_codecID": 0,
      "networkID": "12345",
      "blockchainID": "2eNy1mUFdmaxXNj1eQHUe7Np4gju9sJsEtWQ4MX3ToiNKuADed",
      "outs": [],
      "ins": [
        {
          "_typeName": "TransferableInput",
          "_typeID": null,
          "_codecID": null,
          "input": {
            "_typeName": "SECPTransferInput",
            "_typeID": 5,
            "_codecID": 0,
            "sigIdxs": [
              {
                "_typeName": "SigIdx",
                "_typeID": null,
                "_codecID": null,
                "bsize": "4",
                "bytes": "00000000",
                "source": "3cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c"
              }
            ],
            "amount": "300000000000000000"
          },
          "txid": "2fombhL7aGPwj3KH4bfrmJwW6PVnMobf9Y2fn9GwxiAAJyFDbe",
          "outputidx": "1",
          "assetID": "2fombhL7aGPwj3KH4bfrmJwW6PVnMobf9Y2fn9GwxiAAJyFDbe"
        }
      ],
      "memo": "41564d207574696c697479206d6574686f64206275696c644578706f7274547820746f206578706f7274204156415820746f2074686520502d436861696e2066726f6d2074686520582d436861696e",
      "destinationChain": "11111111111111111111111111111111LpoYY",
      "exportOuts": [
        {
          "_typeName": "TransferableOutput",
          "_typeID": null,
          "_codecID": null,
          "output": {
            "_typeName": "SECPTransferOutput",
            "_typeID": 7,
            "_codecID": 0,
            "locktime": "0",
            "threshold": "1",
            "addresses": [
              {
                "_typeName": "Address",
                "_typeID": null,
                "_codecID": null,
                "bsize": "20",
                "bytes": "3cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c"
              }
            ],
            "amount": "299999999999000000"
          },
          "assetID": "2fombhL7aGPwj3KH4bfrmJwW6PVnMobf9Y2fn9GwxiAAJyFDbe"
        }
      ]
    }
  },
  "credentials": [
    {
      "_typeName": "SECPCredential",
      "_typeID": 9,
      "_codecID": 0,
      "sigArray": [
        {
          "_typeName": "Signature",
          "_typeID": null,
          "_codecID": null,
          "bsize": "65",
          "bytes": "34fee7c44a85bfcd7c7ae92d5b0d37f40e2bfb85126b7d1edb966470407daa020bd64395a3d4d3dea9f210a85c27acec85f261423b4c1f79c0fc7afce2d99f9101"
        }
      ]
    }
  ]
}

If what you're looking for is not in there, then you'd need to use Ortelius
https://docs.avax.network/build/tools/ortelius

Closing due to inactivity and age, but we can reopen if the above doesn't help.

from avalanchejs.

Related Issues (20)

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.