BUIP199: NexScript Phase 2

BUIP199: NexScript Phase 2
Submitted by Singularity
19 October 2023

Background

The original BUIP187: ‘CashScript Port To Nexa’ is now complete, having completed all the objectives (although being shipped a little later than planned). The NexScript project has successfully completed the objectives of:

  • Producing a new high-level language and smart-contract tool to develop Nexa smart-contracts.
  • Porting CashScript to work with Nexa.
  • Added some of the new functionality in Nexa such as GROUP tokens, visible params and unused params.
  • Fork the CashScript website and add documentation specific to Nexa.

This work can be found at https://nexscript.org and Otoplo / Nexscript · GitLab

Motivation

The motivation for this project is to take the existing work on NexScript and expand it to have larger coverage of the capabilities native to Script in Nexa and bring NexScript functionality much closer to those of Solidity. NexScript already unlocks a huge amount of potential of smart-contracts on Nexa and makes building and managing them considerably easier than using raw script directly, but it’s important we continue a path to providing ever more complex smart-contract capabilities to enable advances DeFi use cases. Nexa has a lot more capability that can be unlocked.

Objectives

  • Develop a set of new opcodes to allow Nexa to come closer to EVM functionality without corrupting the scalability of the network.
    • OP_UNROLL = The inverse of OP_ROLL to allow stack items to be inserted deeper into the stack.
    • OP_CONVERT = To convert stack values to minimally encoded pushes ready to be added to covenant script. This allows contracts to dynamically write contracts.
    • Others that need further research.
  • Expand NexScript to include:
    • Port any new work from CashScript over to NexScript.
    • CheckMerkle to check a merkle proof against a merkle root.
    • Execute function.
    • MerkleTreeUpdate function to update a merkle tree within an updated or new leaf.
    • Research focussed on dynamic multiplex contracts which can self update their contract code via iterations and interactions with other contracts.
    • Research making use of NFTs as contract entity IDs.
    • MAST for data storage UTXOs where write-access to data storage is separated from write access to funds.
    • Using multiple different contracts within the inputs of a single transaction.
    • Updating contract compilation using the efficiency improvements achieved via any new opcodes.
    • Develop a larger library of example contracts for developers to build on top of.
    • Develop and implement an Open Contract System that enables NexScript contracts (including: standard, MAST, multiplex, and potentially dynamic multiplex) to be ‘registered’ on-chain via an open protocol making use of group token creations and indexers to provide wallet software with the data they need to interact with any contracts that their addresses have access-permissions for.
    • Produce documentation for all new features added.
    • Complete all work by the end of Q1 2024.

Funding

Budget of $60,000. This covers research, development and maintenance work by Otoplo Ltd.

The elected B.U. officials: President, Secretary and Developer will jointly agree expenditures for this BUIP and will monitor progress through regular reviews.

Maintenance

Otoplo Ltd will be expected to also provide at least 9 months of software maintenance, including bug fixes, and any updates needed to keep the software functional and secure. This is included in the budget.

Bitcoin Unlimited will be expected to maintain the hosting for any websites that are required for the project.

Licensing

Any new software assets that result from this project will be owned by B.U. Org and will be provided open-source under the MIT license.

Expected Impact

  • Reduce barriers to entry for developers to build smart-contracts on Nexa.
  • Speed up development time for Nexa tools and services.
  • Increase the number of developers coming and building on Nexa.
4 Likes

Just wanted to comment and say how much I appreciate the work that Otoplo has done (and continues to do) wrt coordinating this work effort.

I’ve already had the pleasure of working with NexScript and the nexc compiler. I could not be more satisfied with the final product.

Besides NexScript, I’m also looking forward to the addition of the new GROUP OP codes that will greatly improve the efficiency of the current contracts (using split workarounds).

And thanks to all others involved (namely mainnet_pat) who continue to improve the Script capabilities of Nexa.

Cheers!
Shomari

4 Likes

definitely we need to keep pushing scripting capabilities forward!

4 Likes

----BITCOIN MESSAGE----
BUIP199: Accept
----BITCOIN SIGNATURE----
H+U/UV0y1FGEVNAKdRoUFle0+XQhwSfNnstXvKwSP1VocIcXH/EaRmG2kNRqCQ9ntEtky3hlwvgLmXRlocFFD0U=
----BITCOIN END SIGNATURE----

-----BEGIN BITCOIN SIGNED MESSAGE-----
BUIP199: Accept
-----BEGIN BITCOIN SIGNATURE-----
H242yRJAD341JVqdwnQllvN0K4TH55BJ8KsQAtgTP8s0TsSUWUz0QPfTLcz98O3yZYQ1qnXAbGB1hCQSBgfWf4M=
-----END BITCOIN SIGNATURE-----