How would someone claim cashscript p2sh funds with their authorized address?
Could be for any simple example on the cashscript.org website.
Posted Feb 22, 2023, 10:11 PM UTC
74
Could be for any simple example on the cashscript.org website.
Posted Feb 22, 2023, 10:11 PM UTC
This is the example from p2pkh.cash showing a simple authorized address example:
This contract only has one function. It checks the hash of the public key provided to spend matches the public key hash specified for the contract, then it checks that the signature is valid for that public key.
You can input it here:
https://playground.cashscript.org/
And funds the contract (through funds sent via your testnet wallet). To switch between wallet view and contract view, there is an ⇆ icon in the upper right of the playground.
There are free coins from here:
https://tbch4.googol.cash/
The op codes in the redeem script actually being generated under the hood look like this:
<the authorized public key hash bytes20> OP_OVER OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG
If you get an error submitting the transaction, you can debug it with the
meepcommand, if you install the meep debugger.If you wanted to call the spend from javascirpt, it would be something like:
If you wanted to use it from another language, you could use mainnet.cash. The documentation to use it from REST is here
Thank you. I’m aware of the playground and the wallet there and the test net redemption process into a playground test net wallet. I’d like to redeem from p2sk on main net to a wallet outside of the playground.
Another language is ok. I’ll look at mainnet.cash.
Where would that JavaScript code be deployed? Would I have to set up a node or connect to an api just to claim a p2sh address?
Is there no way yet to do this from cashscript playground on main net to an external wallet?
You should be able to run the p2pkh.js example if you checkout the CashScript project and do:
So if you copied that example and put your private key in, it would submit the signed transaction from nodejs.
Obviously, you have to update the script to be your script, and the ElectrumNetworkProvider should be
mainnet.The example is using Alice's wallet, but you can change it to keys you got from Electron Cash.
[deleted]