Search code examples
rustsubstratepolkadot-js

UTXO Workshop: how to get Alice's sigscript?


This might be a stupid question...

I was playing around the utxo-workshop, and there's a comment below asking on how to get alice's sigscript.

I tried following the procedure in the test cases found in utxo.rs:

let alice_signature = sp_io::crypto::sr25519_sign(SR25519, &alice_pub_key, &transaction.encode()).unwrap();
transaction.inputs[0].sigscript = H512::from(alice_signature);

But it returns an error: called `Option::unwrap()` on a `None` value.

I'm guessing the Transaction should look like this:

{
  "inputs": [
    {
      "outpoint": "0x76584168d10a20084082ed80ec71e2a783abbb8dd6eb9d4893b089228498e9ff",
      "sigscript": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
    }
  ],
  "outputs": [
    {
      "value": 50,
      "pubkey": "0x8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48"
    }
  ]
}

How do I get the Alice Signature on a transaction where she spends 50 utxo on Bob: 0x6ceab99702c60b111c12c2867679c5555c00dcd4d6ab40efa01e3a65083bfb6c6f5c1ed3356d7141ec61894153b8ba7fb413bf1e990ed99ff6dee5da1b24fd83?

Or how can I do it in polkadot.js?


Solution

  • Okay, basically I just used the Pair to sign the transaction inside the chain_spec.rs of the node module.

    And also just did it literally outside the project, from the polkascan.