Page MenuHomePhabricator

[Apps][Examples] Smart contract where only the designated signature can withdraw XEC
AbandonedPublic

Authored by emack on Aug 8 2023, 15:40.

Details

Reviewers
bytesofman
Fabien
Group Reviewers
Restricted Project
Summary

T3203

The CashScript used here is a high-level programming language for smart contracts forked for the eCash chain by community dev Sam Rock. It offers a strong abstraction layer over eCash's native virtual machine, Bitcoin Script. Its syntax is based on Ethereum's smart contract language Solidity, but its functionality is very different since smart contracts on eCash differ greatly from smart contracts on Ethereum.

The example here consists of a CashScript contract (p2pkh.cash) which is compiled using the CashScript compiler into a JSON output (p2pkhContract.json), which is then imported into JS modules (p2pkhContract.js) to facilitate interactions with that contract.

Note: this eCash fork of CashScript was split from CashScript v0.6.5 which was the last version before they implemented introspection opcodes, cashtokens support...etc.

Overview:

  • /contracts/p2pkh.cash is the contract in the CashScript language which takes in a public key hash at the point of creation and ensures only the matching public key and signature can unlock the spend() function.
  • /contracts/p2pkContract.json is the output from compiling the CashScript contract, which is imported into js files for contract interaction.
  • /scripts/p2pkhContract.js contains the createP2pkhContract() function which instantiates CashScript via Chronik and creates a new contract based on the supplied public key hash. Its entry point function calls createP2pkhContract() and then displays the contract address/balance before sending a nominal amount in sats back to the contract
Test Plan
  • Update /scripts/p2pkhContract.js with private key, public key hash and public keys
  • npm run createP2pkhContract
  • npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
cashscriptP2pkh
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 24715
Build 49022: Build Diffapp-dev-examples
Build 49021: arc lint + arc unit

Event Timeline

emack requested review of this revision.Aug 8 2023, 15:40
Fabien requested changes to this revision.Aug 9 2023, 11:00
Fabien added a subscriber: Fabien.

That's cool but we shouldn't provide usage examples for external libraries, as this is impossible to maintain. Also we have no control over the code quality.

This revision now requires changes to proceed.Aug 9 2023, 11:00
emack planned changes to this revision.Aug 10 2023, 06:36

On hold until we're in a position to fork our own version

This could be "changes planned" for quite some time. Okay to abandon it and mention this diff in a task, so it can be referenced later.