Skip to main content

Continuous Upgrades to the NOTE Protocol

· 6 min read

Since the public release of its Proof of Concept indexer in February 2024, the NOTE protocol has garnered widespread attention. Following feedback and demands from users, the protocol has been continuously upgraded.

As of April 4th, the following upgrades have been implemented:

  • The Payload data area has been fully expanded, meaning that Payload data can now be stored either in the unlocking script or in the redemption script.
  • Added a Burn method to N20. Tokens can now be burned.
  • The off-chain contract execution environment has been enriched with a plethora of environmental variables, including block information such as block time, block hash, block height, as well as transaction information like transaction hash, all inputs and outputs. Ticker information, such as the total mint amount, etc., has also been included.

The indexer code has undergone extensive refactoring.

One of the goals of this upgrade is to enable anyone to participate in the development of NOTE smart contracts. This allows for the creation of unique smart contracts that can be published to the NOTE indexer, facilitating the issuance of digital assets. A comprehensive tutorial on contract creation is currently being developed.

The capabilities of the NOTE protocol can be seen in the POW mining contract released in February.

We've added some comments to help everyone understand:

// Each contract is a subclass of SmartContract, and its member variables are read-only and need to be decorated with @prop().
export class N20_Pow extends SmartContract {
@prop()
readonly tick: ByteString

@prop()
readonly max: bigint

@prop()
readonly lim: bigint

@prop()
readonly dec: bigint

@prop()
readonly bitwork: ByteString

@prop()
readonly start: bigint

// If the contract includes member variables, they need to be initialized using a constructor.
constructor(tick: ByteString, max: bigint, lim: bigint, dec: bigint, bitwork: ByteString, start: bigint) {
super(...arguments)
// The identifier of the digital asset, its name.
this.tick = tick
// The maximum issuance of the digital asset, if there is no limit, it can be specified as 0.
this.max = max
// The mining limit per transaction, it cannot exceed the maximum value.
this.lim = lim
// The decimal unit of the digital asset, for example, if dec=8, then 1 token should be followed by 8 zeros, all quantity values amt, including max and lim, are affected by this. 100000000 represents 1.00000000.
this.dec = dec
// Mining difficulty, the required leading characters of each transaction's hash256.
this.bitwork = bitwork
// The starting height of the mining contract, used to prevent pre-mining.
this.start = start
}

// The block limit algorithm for mining, needs to be decorated with @method().
@method()
getBlockLimit(height: bigint): bigint {
assert(height >= this.start, 'Block height is too low')
// Halving occurs every 1000 blocks, the number of halvings is determined by the block height minus the starting height.
let halvings = (height - this.start) / 1000n
// A maximum of 7 halvings.
halvings = halvings > 7n ? 7n : halvings
// The mining quantity limit is halved with each halving. Here, the binary rshift operator is used to perform the division by 2 operation.
const subsidy = rshift(this.lim, halvings)
return subsidy
}

// The quantity limit algorithm for mining, needs to be decorated with @method().
@method()
getAmountLimit(currentMined: bigint): bigint {
// The quantity limit starts from how much of the total amount has already been mined.
let miningAmount = this.lim
let threshold = this.max / 2n

// Loop 7 times, each loop, if the current mined amount reaches the threshold, then the mining amount is halved, and the threshold is updated.
for (let halving = 0n; halving < 7n; halving++) {
if (currentMined >= threshold) {
miningAmount /= 2n // Halve the mining amount
threshold += rshift(this.max, halving + 2n) // Update the next threshold
}
}

return miningAmount
}

@method()
public mint(tick: ByteString, amt: bigint, total: bigint, height: bigint, tx: ByteString) {
// Check if the transaction's hash256 leading characters match the mining contract's difficulty requirement.
const txid = hash256(tx)
assert(slice(txid, 0n, len(this.bitwork)) == this.bitwork, 'not match target')
// Check if the total mining amount exceeds the maximum issuance.
assert(this.max == 0n || total <= this.max, 'Over max')
assert(tick == this.tick, 'Tick does not match')
// Check if the mining amount exceeds the block limit and the total halving limit.
const limit1 = this.getBlockLimit(height)
const limit2 = this.getAmountLimit(total)
const limit = limit1 > limit2 ? limit2 : limit1
assert(amt <= limit && amt <= this.max - total, 'Amount check failed')
}

// The method for transferring Tokens, needs to be decorated with @method().
@method()
public transfer(tick: ByteString) {
assert(tick == this.tick, 'Tick does not match')
}
}

there is a bug in the above code about max=0. if you want to use it in your assets, please DONT set max=0.

This upgrade added the Burn method, allowing for the burning of Tokens. A new example is as follows.

// This example does not use a constructor but instead uses a static setting of parameters, because the values are entirely within the contract and cannot be reused for other digital assets.
export class N20_Joss extends SmartContract {
// Joss paper: A type of paper made to resemble money and burned in front of deities.
@prop()
static tick: ByteString = toByteString('JOSS', true)

// No issuance limit.
@prop()
static max: bigint = 0n

// Can issue 10,000 at a time.
@prop()
static lim: bigint = 10000n

// No decimal places.
@prop()
static dec: bigint = 0n

@method()
public mint(tick: ByteString, amt: bigint) {
assert(tick == N20_Joss.tick, 'Tick does not match')
// The issuance amount cannot exceed the limit of 10,000.
assert(amt == N20_Joss.lim, 'Limit does not match')
}

@method()
public transfer() {
// Cannot transfer.
assert(false)
}

@method()
public burn(tick: ByteString) {
// Can be burned.
assert(tick == N20_Joss.tick, 'Tick does not match')
}
}

The N20_Joss contract was released at https://mempool.space/tx/c2cda4c9da3a91bd245d9f6250b5ca8f2ec81d50c14821e87a033fde1f3b5561

Support for smart contracts is the biggest difference between the NOTE protocol and other protocols. The NOTE wallet and indexer create an execution environment for smart contracts, allowing users to write their own smart contracts. For basic knowledge about smart contracts, you can refer to:

Why Bitcoin smart contracts are Turing complete:

A tutorial on smart contract development for the NOTE protocol is being created, so stay tuned.

N20 Token protocol draft is out

· 10 min read

The NOTE protocol marks a significant advancement in the history of Bitcoin.

The NOTE protocol is a digital asset issuance protocol based on Bitcoin's UTXO model, distinct from many recently emerged protocols, as NOTE is genuinely rooted in Bitcoin's UTXO model. It utilizes a smart contract language compatible with Typescript, whose compilation results in Bitcoin native opcodes, enabling a powerful feature set that includes Oracles and zero-knowledge proofs.

Unlike protocols such as Ordinals and Atomicals, NOTE also uses an indexer to tally user assets, but it is entirely based on cryptography, secured by Bitcoin miners to ensure asset ownership, thus avoiding misoperations due to indexer tagging. Moreover, NOTE's transaction costs are extremely low, eliminating the need to send two transactions as with Ordinals and Atomicals. More importantly, the NOTE protocol supports smart contracts, for instance, enabling Bitwork mining and a diminishing mining quantity over time. It employs actual Token values, not based on prime protocols numbered by Satoshi nor dependent on UTXO balance coloring schemes.

Compared to many "inter-chain bridging protocols," NOTE issues native Bitcoin assets, avoiding operations that involve using BTC as collateral to issue and trade assets on other chains.

ProtocolOrdinals/BRC20Atomicals/ARC20EVM/Zk Layer2NOTE/N20
UTXOYESYESNOYES
Bitcoin AssetsYESYESNOYES
Smart ContractNONOYES(EVM)YES(Bitcoin OP Codes)
IndexerYESYESNOYES
Index LogicSatoshi OrdinalsColored Satoshi-Cryptography
Cross Chain TransferNONOYES with bridgeYES
Fee(Gas)HighHighMedium-LowLow
FundNOunknownYES or unknownNO

The NOTE protocol supports cross-chain functionality, allowing native assets on Bitcoin to be sent to other UTXO chains, as well as receiving assets from these chains. All of this is based on cryptography and the consensus of the Bitcoin blockchain.

This protocol is entirely the result of open-source contributions from Bitcoin development luminaries, with no institutional investment involved.

Now, let's delve into a detailed technical interpretation:

The last bull market was ignited by a large number of institutional investment projects and ultimately collapsed with the downfall of institutions like FTX. Starting from the bear market bottom in 2023, the market has returned to the grassroots and developer enthusiasts' home ground. Inscriptions led the market trend without any investment, bringing the advantages of the UTXO model back into the public eye. As the anchor of digital currency, Bitcoin needs usable and practical technological solutions to achieve asset appreciation and practical applications.

Compared to the EVM, Bitcoin's UTXO model has significant efficiency and concurrency advantages. However, issuing native assets on Bitcoin's UTXO model involves several challenging issues, mainly how assets are identified. Another issue is how assets are preserved in closely linked transactions.

A UTXO-style transaction is illustrated as follows:

Image1

The NOTE protocol adopts an innovative approach to managing Bitcoin transactions and assets, significantly different from other protocol solutions. In traditional Bitcoin transactions, the input part of a transaction unlocks a previous transaction's output (i.e., the old UTXO) and generates new transaction outputs (i.e., new UTXOs). In other protocol solutions, assets are tied to newly generated UTXOs, causing users' assets to be scattered across different UTXOs. This method requires indexers and wallets to maintain a comprehensive list of UTXOs to ensure the accuracy of asset binding relationships. It also necessitates careful management of UTXOs with asset tags to avoid spending mistakes, and the entire UTXO must be spent at once.

In contrast, the NOTE protocol employs a method that treats transaction outputs as user accounts, where a user's account is represented by the transaction output script hash, as illustrated by the TX1 transaction output in the example. This account is entirely private, and the types and quantities of assets tied to it are derived from the unlocking inputs of TX1. When these assets are spent in TX2, after being unlocked and confirmed by Bitcoin miners, new transaction outputs are generated. During this process, the indexer of the NOTE protocol only needs to record the transaction details disclosed at the time of unlocking and can provide a Merkle proof after block confirmation to verify the transaction's validity.

This design not only simplifies asset tracking and management, reducing the issue of asset fragmentation, but also enhances transaction privacy. By using transaction outputs as accounts and relying on the verification by Bitcoin network miners and the blockchain consensus mechanism, the NOTE protocol offers a more secure, efficient, and privacy-preserving method for managing digital assets.

A typical Taproot P2TR format transaction is illustrated as follows:

Image2

The technical strategy adopted by the NOTE protocol significantly differs from the Ordinals and Atomicals protocols. Ordinals and Atomicals utilize the redemption script of P2TR (Taproot) to create an inaccessible data area by adding OP_FALSE OP_IF opcodes, embedding additional data. In contrast, the NOTE protocol allows direct manipulation of unlocking data through opcodes, enhancing data usability. In the NOTE protocol, example scripts can directly pop data from the stack, while more complex scripts can perform on-chain checks such as hashlock.

Moreover, the NOTE protocol is not limited to using P2TR; it can also be implemented through P2SH (Pay to Script Hash), P2WSH (Pay to Witness Script Hash), and non-standard scripts, increasing the protocol's flexibility and the capability for cross-chain asset transactions. A key innovation of the NOTE protocol is its use of msgpack encoding instead of json encoding for data, which is more compact and helps reduce the data volume per transaction, thereby lowering transaction costs for users.

In the NOTE protocol, addresses constructed by specific redemption scripts act as user accounts. These account addresses can only be confirmed by miners when correctly unlocked. The asset transaction data contained in the unlocking script is recognized by the indexer upon unlocking and processed by off-chain smart contracts. Only asset transactions verified by off-chain contracts are recorded by the indexer, effectively preventing Bitcoin wallets from mistakenly spending NOTE's UTXO and allowing the recovery of small amounts of Bitcoin (e.g., 546 Satoshi) in UTXOs.

The design of the NOTE protocol considers multiple upgrades to privacy and transaction space optimization in the Bitcoin network since 2017. At the same time, it draws on the large block strategy represented by BSV (Bitcoin SV), delving into the potential of Bitcoin scripting. The smart contract solution of the NOTE protocol is based on the Bitcoin smart contract language developed by the sCrypt team, which supports off-chain contract verification. Since the Bitcoin script language is Turing complete and ensures execution within a given script length, indexers are not trapped in infinite loops due to poorly designed smart contracts, ensuring system stability and efficiency.

A demo smart contract project has been released on GitHub.

https://github.com/NoteProtocol/scryptdemo

Image3

It demonstrates the capability of the NOTE protocol to implement complex logic on the Bitcoin network through simulating Bitcoin mining's halving mechanism and Atomicals' Bitwork difficulty mining with a PoW contract. By generating a 1KB Bitcoin script, the contract allows indexers to call and verify whether transactions comply with the protocol, showcasing the feasibility and flexibility of smart contracts on the Bitcoin network.

The use of Rabin signature algorithm Oracles and complex contracts based on zero-knowledge proofs provides a higher level of security and privacy protection. These technologies play a crucial role in the implementation of smart contracts, especially when verifying specific conditions or executing particular logic.

Leveraging these smart contracts, asset issuance on Bitcoin can be used to realize real-world application scenarios, such as bounty scenarios for solving problems with AI. In such scenarios, anyone who can submit a verifiable computational result can receive a reward. This not only demonstrates the practicality of Bitcoin smart contracts but also shows how they can facilitate the realization of complex applications beyond traditional financial transactions and asset management.

The application prospects and implementation mechanisms of smart contracts on the Bitcoin network reflect an important direction in the development of cryptocurrency technology: combining blockchain's decentralization and immutability with complex business logic and application scenarios to explore new possibilities. For those interested in delving deeper or participating in development, following and learning from these smart contract projects and their implementations on GitHub is undoubtedly a valuable resource.

The latest developments and announcements of the NOTE protocol showcase its depth and breadth in the blockchain technology field. The issuance of N20 Token assets is just one of the many functions of the NOTE protocol. It also includes DID (Decentralized Identity), encrypted data, and ownership identification, and with the formulation and verification process of N721 NFTs and Alias (Bitcoin alias system), the capabilities and application scope of the NOTE protocol are expected to expand further.

Currently, to allow users to experience the minting and transferring of N20 Tokens, a command-line wallet has been released on GitHub, and an open-source indexer is also planned to be released. The openness of these tools and resources aims to encourage community member participation and practical experience with the NOTE protocol's functions, thereby accelerating the protocol's testing, improvement, and application development.

The open-source contributors behind the NOTE protocol emphasize that all content is for technical discussion only, and any asset issuance and speculation are unrelated to the contributors. This stance encourages a community environment centered on technology and innovation, rather than speculation and investment.

As the NOTE protocol continues to be developed and refined, it is foreseeable that more real applications based on this protocol will emerge. These applications will leverage the unique functions and advantages of the NOTE protocol to create new value and possibilities in Bitcoin and broader blockchain fields. The ongoing contributions and collaborative spirit of the open-source community are indispensable forces driving this process.

Summary

The NOTE protocol represents a significant advancement in the expansion of the Bitcoin network towards smart contract functionality. By introducing smart contracts to Bitcoin, the most original and widely used cryptocurrency platform, the NOTE protocol not only enhances Bitcoin's functionality but also offers unprecedented possibilities for innovation to developers and users. Here are several key features of the NOTE protocol:

Smart Contract Support: The NOTE protocol extends the application range of Bitcoin through smart contracts, allowing for the creation and execution of more complex logic and transaction types on the Bitcoin network. This includes, but is not limited to, asset issuance, decentralized finance (DeFi) applications, and other scenarios requiring conditional execution.

UTXO-based Model: Unlike account-based smart contract platforms, the NOTE protocol is built on Bitcoin's UTXO model, leveraging Bitcoin's security and efficiency.

Cross-chain Functionality: The NOTE protocol supports cross-chain transactions, enabling digital assets to move between different UTXO chains, further enhancing its flexibility and application scope.

Real-world Applications: The NOTE protocol supports advanced cryptographic technologies, such as zero-knowledge proofs and Rabin signature algorithms, which can be applied in more complex real-world application scenarios.

Low Cost and High Efficiency: By optimizing data storage and using msgpack encoding, the NOTE protocol aims to reduce transaction costs and improve network efficiency.

Open Source and Community-driven: The NOTE protocol emphasizes the spirit of open source and community contribution, promoting the transparency and trustworthiness of the technology while also encouraging broader development and application innovation.

As the NOTE protocol continues to develop and its applications deepen, we can expect to see more innovative applications and services emerging in the Bitcoin ecosystem, all of which will provide users with richer functionality and a better experience while maintaining Bitcoin's core values.

Website: https://noteprotocol.org

X: https://twitter.com/NoteProtocol

GitHub: https://github.com/NoteProtocol

Smart Contract Language: https://docs.scrypt.io/

NoteProtocol v2.0 Draft is out

· One min read

🚀 Exciting update from our team: We’ve crafted a #Bitcoin protocol, tailored for #UTXO-based blockchains. This protocol not only allows for the creation of tokens and NFTs but also integrates optional data #encryption, #SmartContracts, and #DID definitions, all under the MIT License.

🔬 The first segment has been successfully tested on #BTC, #RXD, and #BSV networks. The #NFT/#Token/Indexer features are nearing completion, with a January release following thorough validation to ensure a high-security standard.

🌍 As we move forward, we’re inviting the community to contribute to this evolving project. Our goal is to establish a protocol committee of contributors, dedicated to promoting and enhancing the protocol, ensuring it serves the global Bitcoin community effectively.

🔧 Your input is vital in this journey of innovation and collaboration. We’re here to support projects leveraging this protocol, fostering a secure and dynamic blockchain ecosystem.

🔔 Stay connected for detailed updates and be part of shaping the future of blockchain technology. #BlockchainEngineering #BitcoinProtocol #DecentralizedInnovation #OpenSourceFuture

Happy New Year everyone!