diff --git a/docs/tokens/ft/existing.md b/docs/tokens/ft/existing.md index 3790c3407..4bb16fe01 100644 --- a/docs/tokens/ft/existing.md +++ b/docs/tokens/ft/existing.md @@ -17,9 +17,9 @@ const recipient = new HashLockFT(tick, max, lim, dec, hash); await recipient.connect(getDefaultSigner()); // Create P2PKH object from an UTXO -// NOTE: You can not use BSV20V2P2PKH.getLatestInstance for BSV-20, it only works for NFTs. +// NOTE: You can not use BSV21P2PKH.getLatestInstance for BSV-20, it only works for NFTs. const utxo: UTXO = ... -const p2pkh = BSV20V2P2PKH.fromUTXO(utxo); +const p2pkh = BSV21P2PKH.fromUTXO(utxo); await p2pkh.connect(getDefaultSigner()); // Unlock it and transfer the FTs carried by it. @@ -29,7 +29,7 @@ const { tx: transferTx } = await p2pkh.methods.unlock( { transfer: recipient, pubKeyOrAddrToSign: `yourPubKey`, - } as OrdiMethodCallOptions + } as OrdiMethodCallOptions ); console.log("Transferred FT: ", transferTx.id); @@ -41,8 +41,8 @@ Alternatively, you can unlock multiple FT UTXOs and send them to a smart contrac // ... initialize recipient smart contract // Fetch FT UTXOs for given Ordinal address. -// NOTE: You can not use BSV20V2P2PKH.getLatestInstance for BSV-20, it only works for NFTs. -const bsv20P2PKHs = await BSV20V2P2PKH.getBSV20(tokenId, `your ordinal address`); +// NOTE: You can not use BSV21P2PKH.getLatestInstance for BSV-21, it only works for NFTs. +const bsv20P2PKHs = await BSV21P2PKH.getBSV20(tokenId, `your ordinal address`); await Promise.all(bsv20P2PKHs.map((p) => p.connect(signer))); @@ -78,7 +78,7 @@ const { tx: transferTx } = await p2pkh.methods.unlock( transfer: recipient, pubKeyOrAddrToSign: `yourPubKey`, tokenChangeAddress: yourOrdinalAddress - } as OrdiMethodCallOptions + } as OrdiMethodCallOptions ) ``` @@ -91,18 +91,18 @@ const { tx: transferTx } = await p2pkh.methods.unlock( transfer: recipient, pubKeyOrAddrToSign: `yourPubKey`, skipTokenChange: true - } as OrdiMethodCallOptions + } as OrdiMethodCallOptions ) ``` # `buildStateOutputFT` -Any instance of `BSV20V1` or `BSV20V2` contains the `buildStateOutputFT` method. Unlike the regular `buildStateOutput` method, this method inscribes the subsequent amount with an appropriate [BSV-20 transfer inscription](https://docs.1satordinals.com/bsv20#transfer-all-modes). The method takes the number of tokens to be transferred to the subsequent output as an argument. +Any instance of `BSV20` or `BSV21` contains the `buildStateOutputFT` method. Unlike the regular `buildStateOutput` method, this method inscribes the subsequent amount with an appropriate [BSV-20 transfer inscription](https://docs.1satordinals.com/bsv20#transfer-all-modes). The method takes the number of tokens to be transferred to the subsequent output as an argument. Below is an example of an FT counter contract: ```ts -class CounterFTV2 extends BSV20V2 { +class CounterFTV2 extends BSV21 { @prop(true) counter: bigint diff --git a/docs/tokens/ft/ft.md b/docs/tokens/ft/ft.md index c11452184..0b4986c19 100644 --- a/docs/tokens/ft/ft.md +++ b/docs/tokens/ft/ft.md @@ -8,18 +8,18 @@ Just like NFTs, `scrypt-ord` also supports fungible tokens. Under the hood it ut BSV-20 is a protocol for creating fungible tokens on the Bitcoin SV blockchain. Fungible tokens are interchangeable with each other, and can be used to represent a variety of assets, such as currencies, securities, and in-game items. -`scrypt-ord` supports both v1 and v2 of the `BSV-20` FT protocol. +`scrypt-ord` supports both `BSV-20` and `BSV-21` of the FT protocol. -## v1 +## `BSV-20` Tokens utilizing the first version of the `bsv-20` must be initialized by a **deployment** inscription, which specifies the token's ticker symbol, amount and mint limit. For more information, refer to the [1Sat docs](https://docs.1satordinals.com/bsv20#v1-mint-first-is-first-mode). -To create a v1 token smart contract, have it extend the `BSV20V1` class: +To create a v1 token smart contract, have it extend the `BSV20` class: ```ts -class HashLockFT extends BSV20V1 { +class HashLockFT extends BSV20 { @prop() hash: Sha256 @@ -36,7 +36,7 @@ class HashLockFT extends BSV20V1 { } ``` -As you can see above, the constructor of contract extending the `BSV20V1` takes as parameters all of the needed information for the token deployment, succeeded by other parameters needed you use for your contract (`hash` in this particular example). +As you can see above, the constructor of contract extending the `BSV20` takes as parameters all of the needed information for the token deployment, succeeded by other parameters needed you use for your contract (`hash` in this particular example). Each constructor extending the `BSV20V1` class must also call the instances `init` method and pass the constructors arguments. It is important to call this function **after** the call to `super`. @@ -114,19 +114,19 @@ for (let i = 0; i < 3; i++) { } ``` -Note that the new recipient smart contract instance is passed as a parameter named `transfer` during the call to the deployed instance. The `transfer` parameter is an array of contract instances that extend `BSV20V1`. +Note that the new recipient smart contract instance is passed as a parameter named `transfer` during the call to the deployed instance. The `transfer` parameter is an array of contract instances that extend `BSV20`. -## v2 +## `BSV-21` -Version 2 of the `BSV-20` token protocol simplifies the process of minting a new fungible token. In this version, the deployment and minting are done within a single transaction. Unlike v1, v2 lacks a token ticker field. The token is identified by an `id` field, which is the transaction id and output index where the token was minted, in the form of `_`. +Version 2 of the `BSV-21` token protocol simplifies the process of minting a new fungible token. In this version, the deployment and minting are done within a single transaction. Unlike `BSV-20`, `BSV-21` lacks a token ticker field. The token is identified by an `id` field, which is the transaction id and output index where the token was minted, in the form of `_`. Please refer to the [official 1Sat documentation](https://docs.1satordinals.com/bsv20#new-in-v2-tickerless-mode) for more info. -To create a v2 token smart contract, have it extend the `BSV20V2` class: +To create a `BSV-21` token smart contract, have it extend the `BSV21` class: ```ts -class HashLockFTV2 extends BSV20V2 { +class HashLockFTV2 extends BSV21 { @prop() hash: Sha256 @@ -145,7 +145,7 @@ class HashLockFTV2 extends BSV20V2 { ### Deploy+Mint -In v1, tokens are deployed and minted in separate transactions, but in v2, all tokens are deployed and minted in one transactions. Here's an example of how you would deploy the new v2 FT: +In `BSV-20`, tokens are deployed and minted in separate transactions, but in `BSV-21`, all tokens are deployed and minted in one transactions. Here's an example of how you would deploy the new `BSV-21` FT: ```ts HashLockFTV2.loadArtifact() @@ -218,6 +218,6 @@ for (let i = 0; i < 3; i++) { } ``` -The new recipient smart contract instance is provided as a `transfer` parameter when calling the deployed instance. The `transfer` parameter consists of an array of contract instances derived from `BSV20V2`. +The new recipient smart contract instance is provided as a `transfer` parameter when calling the deployed instance. The `transfer` parameter consists of an array of contract instances derived from `BSV21`. --- diff --git a/docs/tokens/ft/multiple.md b/docs/tokens/ft/multiple.md index 3cce9fe08..ce10e34f7 100644 --- a/docs/tokens/ft/multiple.md +++ b/docs/tokens/ft/multiple.md @@ -7,7 +7,7 @@ Suppose we would like to unlock FTs within a single transaction that are located ```ts // One sender is regular bsv-20 P2PKH. -const sender0 = BSV20V2P2PKH.fromUTXO(utxo) +const sender0 = BSV21P2PKH.fromUTXO(utxo) await sender0.connect(signer) // Second sender is a hash lock contract. @@ -36,8 +36,8 @@ const ordPubKey = await signer.getDefaultPubKey() sender0.bindTxBuilder( 'unlock', async ( - current: BSV20V2P2PKH, - options: OrdiMethodCallOptions + current: BSV21P2PKH, + options: OrdiMethodCallOptions ): Promise => { const tx = new bsv.Transaction() const nexts: StatefulNext[] = [] @@ -45,7 +45,7 @@ sender0.bindTxBuilder( for (let i = 0; i < recipients.length; i++) { const receiver = recipients[i] - if (receiver.instance instanceof BSV20V2) { + if (receiver.instance instanceof BSV21) { receiver.instance.setAmt(receiver.amt) } else { throw new Error('Unsupported receiver, only BSV-20!') @@ -66,7 +66,7 @@ sender0.bindTxBuilder( } if (tokenChangeAmt > 0n) { - const p2pkh = new BSV20V2P2PKH( + const p2pkh = new BSV21P2PKH( tokenId, amount, dec, @@ -107,7 +107,7 @@ let partialContractTx = await sender0.methods.unlock( { pubKeyOrAddrToSign: ordPubKey, multiContractCall: true, - } as OrdiMethodCallOptions + } as OrdiMethodCallOptions ) sender1.bindTxBuilder( @@ -136,7 +136,7 @@ partialContractTx = await sender1.methods.unlock(message1, { transfer: recipients, pubKeyOrAddrToSign: ordPubKey, multiContractCall: true, -} as OrdiMethodCallOptions) +} as OrdiMethodCallOptions) const { tx } = await SmartContract.multiContractCall( partialContractTx, @@ -146,10 +146,10 @@ const { tx } = await SmartContract.multiContractCall( console.log('Transfer tx:', tx.id) ``` -In the above code, a partial transaction is constructed, which unlocks the first UTXO containing a `BSV20V2P2PKH` instance. The actual contract call doesn't execute yet, as we set the `multiContractCall` flag within the method call parameters. +In the above code, a partial transaction is constructed, which unlocks the first UTXO containing a `BSV21P2PKH` instance. The actual contract call doesn't execute yet, as we set the `multiContractCall` flag within the method call parameters. We then feed that partially constructed transaction via the second contract call, which will unlock the `HashLockFTV2` instance. Just like the first call, this call also has the `multiContractCall` flag set. Once the transaction is fully built, we can sign and broadcast it using the `SmartContract.multiContractCall` function. -The above code is an example based on v2, but the same can be achieved using v1. +The above code is an example based on `BSV-21`, but the same can be achieved using `BSV-20`. diff --git a/docs/tokens/ft/woc-bsv20-plugin.md b/docs/tokens/ft/woc-bsv20-plugin.md index 5d4295f08..c207e08fd 100644 --- a/docs/tokens/ft/woc-bsv20-plugin.md +++ b/docs/tokens/ft/woc-bsv20-plugin.md @@ -44,7 +44,7 @@ The transaction does not contain any BSV20 token input and it has other fields: ------------------------ -[1] We support both BSV20 v1 and [v2](https://docs.1satordinals.com/bsv20#new-in-v2-tickerless-mode). +[1] We support both BSV20 and [`BSV-20`](https://docs.1satordinals.com/bsv20#new-in-v2-tickerless-mode). diff --git a/docs/tokens/tokens.md b/docs/tokens/tokens.md index 50c2b808d..d4aedaac5 100644 --- a/docs/tokens/tokens.md +++ b/docs/tokens/tokens.md @@ -28,13 +28,13 @@ npm i scrypt-ord - `OrdinalNFT` **Fungible tokens (FTs):** -- `BSV20V1` -- `BSV20V2` +- `BSV20` +- `BSV21` There are also pre-made classes that represent standard 1Sat transfers using the widely employed `P2PKH` mechanism: - `OrdiNFTP2PKH` -- `BSV20V1P2PKH` -- `BSV20V2P2PKH` +- `BSV20P2PKH` +- `BSV21P2PKH` Suppose you wish to lock an ordinal token using a custom hash puzzle contract, you would define the smart contract class as shown below: @@ -86,4 +86,4 @@ export function getDefaultSigner(): TestWallet { ### testnet - `gorillapool`: https://testnet.ordinals.gorillapool.io/api/docs -- `scrypt` (only bsv20 v2): https://1sat.scrypt.io/api/docs \ No newline at end of file +- `scrypt` (only bsv21): https://1sat.scrypt.io/api/docs diff --git a/docs/tokens/tutorials/mint-bsv20-v1.md b/docs/tokens/tutorials/mint-bsv20-v1.md index 64f75b2db..ad3d4b09a 100644 --- a/docs/tokens/tutorials/mint-bsv20-v1.md +++ b/docs/tokens/tutorials/mint-bsv20-v1.md @@ -2,7 +2,7 @@ sidebar_position: 3 --- -# Tutorial 3: Mint BSV20 V1 Token +# Tutorial 3: Mint BSV20 Token ## Overview @@ -21,7 +21,7 @@ The new contract `HashLockFT` is almost the same as the previous [implementation 1. It must be derived from `BSV20V1` instead of `SmartContract`. ```ts -class HashLockFT extends BSV20V1 { +class HashLockFT extends BSV20 { ... } ``` @@ -39,7 +39,7 @@ constructor(tick: ByteString, max: bigint, lim: bigint, dec: bigint, hash: Sha25 The contract also stores a hash value in the contract, and it will be unlocked successfully when calling the public method `unlock` with the correct message. ```ts -class HashLockFT extends BSV20V1 { +class HashLockFT extends BSV20 { @prop() hash: Sha256 @@ -52,7 +52,7 @@ class HashLockFT extends BSV20V1 { } ``` -The base class `BSV20V1` encapsulated helper functions to handle BSV20 (version 1) tokens. If you want to create your own contract that can interact with BSV20 protocol, derive from it. +The base class `BSV20` encapsulated helper functions to handle BSV20 (version 1) tokens. If you want to create your own contract that can interact with BSV20 protocol, derive from it. ## Deploy and Mint @@ -85,7 +85,7 @@ For now, the contract instance holds the token and we try to transfer it to a P2 ### Step 1. Create Receiver Instance -Class `BSV20V1P2PKH` represents a P2PKH address that can hold BSV20 version 1 tokens. Its constructor takes BSV20 fields and an receiving address as parameters. +Class `BSV20P2PKH` represents a P2PKH address that can hold BSV20 version 1 tokens. Its constructor takes BSV20 fields and an receiving address as parameters. ```ts const alice = new BSV20V1P2PKH(tick, max, lim, dec, addressAlice) diff --git a/docs/tokens/tutorials/mint-bsv20-v2.md b/docs/tokens/tutorials/mint-bsv20-v2.md index 0d32b59c2..fdc84ad25 100644 --- a/docs/tokens/tutorials/mint-bsv20-v2.md +++ b/docs/tokens/tutorials/mint-bsv20-v2.md @@ -2,11 +2,11 @@ sidebar_position: 2 --- -# Tutorial 2: Mint BSV20 V2 Token +# Tutorial 2: Mint BSV21 Token ## Overview -In this tutorial, we will use contract [HashLock](https://github.com/sCrypt-Inc/boilerplate/blob/master/src/contracts/hashLock.ts) as an example, to introduce how to mint a BSV20 Token (**version 2**) with [sCrypt](https://scrypt.io/) and transfer it with a Smart Contract. +In this tutorial, we will use contract [HashLock](https://github.com/sCrypt-Inc/boilerplate/blob/master/src/contracts/hashLock.ts) as an example, to introduce how to mint a BSV21 Token with [sCrypt](https://scrypt.io/) and transfer it with a Smart Contract. To enable all these features, you should install `scrypt-ord` as an dependency in your project. @@ -18,10 +18,10 @@ npm install scrypt-ord The new contract `HashLockFTV2` is almost the same as the previous [implementation](https://github.com/sCrypt-Inc/boilerplate/blob/master/src/contracts/hashLock.ts), except two differences. -1. It must be derived from `BSV20V2` instead of `SmartContract`. +1. It must be derived from `BSV21` instead of `SmartContract`. ```ts -class HashLockFTV2 extends BSV20V2 { +class HashLockFTV2 extends BSV21 { ... } ``` @@ -39,7 +39,7 @@ constructor(id: ByteString, sym: ByteString, max: bigint, dec: bigint, hash: Sha The contract also stores a hash value in the contract, and it will be unlocked successfully when calling the public method `unlock` with the correct message. ```ts -export class HashLockFTV2 extends BSV20V2 { +export class HashLockFTV2 extends BSV21 { @prop() hash: Sha256 @@ -52,7 +52,7 @@ export class HashLockFTV2 extends BSV20V2 { } ``` -The base class `BSV20V2` encapsulated helper functions to handle BSV20 V2 tokens. If you want to create your own contract that can interact with BSV20 V2 protocol, derive from it. +The base class `BSV21` encapsulated helper functions to handle BSV20 V2 tokens. If you want to create your own contract that can interact with BSV20 V2 protocol, derive from it. ## Deploy Token @@ -82,7 +82,7 @@ For now, the contract instance holds the token and we try to transfer it to a P2 ### Step 1. Create Receiver Instance -Class `BSV20V2P2PKH` represents a P2PKH address that can hold BSV20 V2 tokens. Its constructor takes BSV20 V2 fields and an receiving address as parameters. +Class `BSV20V2P2PKH` represents a P2PKH address that can hold BSV21 tokens. Its constructor takes BSV20 V2 fields and an receiving address as parameters. ```ts const alice = new BSV20V2P2PKH(toByteString(tokenId, true), sym, max, dec, addressAlice ) @@ -113,7 +113,7 @@ This code will create a transaction that transfers 2 tokens to `alice` and 5 to The default transaction builder will automatically add a token change output on the transaction. In this example, it will automatically add a token change output with 3 tokens, paying to the default address of the instance connected signer. You can also specify the token change address by passing the value to the key `tokenChangeAddress` of struct `OrdiMethodCallOptions`. -Execute command `npx ts-node tests/examples/mintBSV20V2.ts` to run this example. +Execute command `npx ts-node tests/examples/mintBSV21.ts` to run this example. ![](../../../static/img/mint-bsv20v2.png)