Sandbox transaction fails with buffer values
Describe the bug
This started with testing a simple Clarity contract that can stack its own STX through pool delegation.
This contract call would not work from the sandbox, however is working from the local test as well as through a custom script.
To Reproduce
Steps to reproduce the behavior:
- Go to https://explorer.stacks.co/sandbox/contract-call?chain=mainnet
- Paste in the contract value:
SP2HNY1HNF5X25VC7GZ3Y48JC4762AYFHKS061BM0.stacking-contract - Click Get contract
- Click
stack-stx - Enter values below:
- amount: 1000
- to: SP1K1A1PMGW2ZJCNF46NWZWHG8TS1D23EGH1KNK60
- poxVer: 0x01
- poxHash: 0x13effebe0ea4bb45e35694f5a15bb5b96e851afb
- until: leave blank (related to #956 fills in
u0and should benone)
The resulting transaction then contains incorrect buffer values, should be (buff 1) and (buff 20):
- poxVer: 0x30783031 (buff 4)
- poxHash: 0x307831336566666562653065613462623435653335363934663561313562623562393665383531616662 (buff 42)
Removing the leading 0x on the hex string results in incorrect values as well:
- poxVer: 0x3031 (buff 2)
- poxHash: 0x31336566666562653065613462623435653335363934663561313562623562393665383531616662 (buff 40)
Using Clarinet testing, the hex string needed to be passed in the tx options.
Using micro-stacks and a script, the hex string needed to be processed as bufferCV(hexToBytes(string)) instead of bufferCVFromString(string) to get the correct value.
Expected behavior
A clear way to know what value to provide, or confirmation that the values provided should be handled a different way.
The correct result for the transaction would be:
- poxVer: 0x01
- poxHash: 0x13effebe0ea4bb45e35694f5a15bb5b96e851afb
Screenshots
From the sandbox:

From the script:

Additional context
Related transaction: https://explorer.stacks.co/txid/dbbecf8113b530bd12ca67c425cc1c27a0bf7916ded65e106cf0ecc8fb28c75a?chain=mainnet
Related issues:
- https://github.com/fungible-systems/micro-stacks/issues/171
- https://github.com/hirosystems/clarinet/issues/786
The current implementation expects that the user enters utf8 that is converted to buffer using encodeClarityValue from stacks.js
This is useful, e.g. for BNS contract. This is not useful for e.g. PoX contract