stacks-archive / stacks-transactions-js

The JavaScript library for generating Stacks 2.0 transactions
19 stars 17 forks source link

Create transactions fails with `Invalid hex string` in browser #58

Closed friedger closed 4 years ago

friedger commented 4 years ago

Using the code below in node environment show a serialized transaction, in a react/browser environment it fails with Invalid hex string:

    const transaction = makeSTXTokenTransfer(
      "ST1T220B88WSF0ZYNS8V7B33DCZEY23FY7V83GDW",
      new BigNum(1000),
      new BigNum(1000),
      "994d526b3b3409def4d3e481f9c4b3debaf9535cffed0769a7543601e1efa3c501",
      {
        nonce: new BigNum(0),
        version: TransactionVersion.Testnet,
        chainId: ChainID.Testnet,
        postConditions: [
          makeStandardSTXPostCondition(
            "ST2P4S7Q4PHGQE9VGG6X8Z54MQQMN1E5047ZHVAF7",
            FungibleConditionCode.Less,
            new BigNum(2000)
          ),
        ],
      }
    );
    console.log(transaction.serialize().toString("hex"));

OS: Ubuntu Browser: Firefox

Steps to reproduce error in app:

  1. git clone https://github.com/friedger/speed-spend.git
  2. yarn
  3. yarn start
  4. Open http://127.0.0.1:3000/ and login
  5. enter friedger.id and press send.
  6. see error the console output.

Steps to reproduce success in node:

  1. git clone https://github.com/friedger/clarity-smart-contracts.git
  2. yarn
  3. yarn mocha 'test/integration/transfer.ts'
  4. see serialized transaction in log (ignore other errors, if any)
friedger commented 4 years ago

Fixed by #66