Skip to content

Commit

Permalink
Update README to reflect MRC20 and MRC721 token standards
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Rey committed Dec 16, 2024
1 parent 46d5e7c commit 7fe25b0
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ If you're interested in learning more about Massa and its capabilities, check ou

## Fungible Token

The [Fungible Token standard implementation](smart-contracts/assembly/contracts/FT) defines a common set of rules for creating and managing Massa-based tokens that are fungible (i.e. interchangeable).
The [Fungible Token standard implementation](smart-contracts/assembly/contracts/MRC20) defines a common set of rules for creating and managing Massa-based tokens that are fungible (i.e. interchangeable).

This is MassaLabs implementation of [the ERC20](https://ethereum.org/en/developers/docs/standards/tokens/erc-20/).

## Non-Fungible Token

The [Non-Fungible Token standard implementation](smart-contracts/assembly/contracts/NFT) defines a common set of rules for creating and managing Massa-based tokens that are non-fungible (i.e. unique).
The [Non-Fungible Token standard implementation](smart-contracts/assembly/contracts/MRC721) defines a common set of rules for creating and managing Massa-based tokens that are non-fungible (i.e. unique).

This is MassaLabs implementation of [the ERC721](https://ethereum.org/en/developers/docs/standards/tokens/erc-721/).

Expand Down
10 changes: 5 additions & 5 deletions smart-contracts/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Massa Smart-contract Standards

- [fungible token](assembly/contracts/FT): implementation of the ERC20 token.
- [non-fungible token](assembly/contracts/NFT)
- [fungible token](assembly/contracts/MRC20): implementation of the ERC20 token.
- [non-fungible token](assembly/contracts/MRC721)

## Documentation

Expand All @@ -22,8 +22,8 @@ npm i @massalabs/sc-standards
```typescript
import { Args } from '@massalabs/as-types';
import { callerHasWriteAccess } from '@massalabs/massa-as-sdk';
import * as FT from '@massalabs/sc-standards/assembly/contracts/FT/index';
export * from '@massalabs/sc-standards/assembly/contracts/FT/token';
import * as MRC20 from '@massalabs/sc-standards/assembly/contracts/MRC20/index';
export * from '@massalabs/sc-standards/assembly/contracts/MRC20/token';

/**
* This function is meant to be called only one time: when the contract is deployed.
Expand All @@ -37,7 +37,7 @@ export function constructor(_: StaticArray<u8>): StaticArray<u8> {
return [];
}

FT.constructor(
MRC20.constructor(
new Args().add('MY_TOKEN').add('MTK').add(4).add(100000).serialize(),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function _uri(_: u256): string {
}

/**
* Set the URI for the NFT contract
* Set the URI for the MRC721 contract
* @param newUri - the new URI
*/
export function _setURI(newUri: string): void {
Expand Down
16 changes: 8 additions & 8 deletions smart-contracts/assembly/contracts/MRC721/MRC721-internals.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/**
* This file contains the internals functions of an NFT contract as defined by the ERC721 standard.
* This file contains the internals functions of a MRC721 contract as defined by the ERC721 standard.
* https://eips.ethereum.org/EIPS/eip-721
*
* DO NOT DEPLOY THIS CONTRACT.
*
* This file is NOT meant to be deployed on its own.
* The functions exposed by this file are meant to be imported and used inside an NFT implementation contract.
* This file can be seen as a library of helper functions that can be used to implement an NFT contract.
* The functions exposed by this file are meant to be imported and used inside an MRC721 implementation contract.
* This file can be seen as a library of helper functions that can be used to implement an MRC721 contract.
*
* The goal of having one separate file for the internals of the NFT contract is
* The goal of having one separate file for the internals of the MC721 contract is
* 1. To abstract the complexity of storage access.
* 2. To guarantee that the storage is accessed in a consistent and gas efficient way.
* 3. To allow developers to focus on the business logic of their NFT contracts.
* 3. To allow developers to focus on the business logic of their MRC721 contracts.
*
* Please check the NFT-example.ts file for an example of how to use this file.
* Please check the ./MRC721.ts file for an example of how to use this file.
*
*/

Expand All @@ -38,12 +38,12 @@ export const ALLOWANCE_KEY_PREFIX: StaticArray<u8> = [0x05];
export const OPERATOR_ALLOWANCE_KEY_PREFIX: StaticArray<u8> = [0x06];

/**
* Constructs a new NFT contract.
* Constructs a new MRC721 contract.
* @param binaryArgs - the binary arguments name and symbol
*
* @remarks This function shouldn't be directly exported by the implementation contract.
* It is meant to be called by the constructor of the implementation contract.
* Please check the NFT-example.ts file for an example of how to use this function.
* Please check the MRC721.ts file for an example of how to use this function.
*/
export function _constructor(name: string, symbol: string): void {
Storage.set(NAME_KEY, stringToBytes(name));
Expand Down
22 changes: 11 additions & 11 deletions smart-contracts/assembly/contracts/MRC721/MRC721.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
*
* This is an example of an NFT contract that uses the NFT-internals
* This is an example of a MRC721 contract that uses the MRC721-internals
* helper functions to implement the ERC721 standard.
*
* This files does basically two things:
* 1. It wraps the NFT-internals functions, manages the deserialize/serialize of the arguments and return values,
* 1. It wraps the MRC721-internals functions, manages the deserialize/serialize of the arguments and return values,
* and exposes them to the outside world.
* 2. It implements some custom features that are not part of the ERC721 standard, like mint, burn or ownership.
*
* The NFT-internals functions are not supposed to be re-exported by this file.
* The MRC721-internals functions are not supposed to be re-exported by this file.
*/

import {
Expand Down Expand Up @@ -60,7 +60,7 @@ export function symbol(): StaticArray<u8> {
* @param binaryArgs - serialized string representing the address whose balance we want to check
* @returns a serialized u256 representing the balance of the address
* @remarks As we can see, instead of checking the storage directly,
* we call the _balanceOf function from the NFT-internals.
* we call the _balanceOf function from the MRC721-internals.
*/
export function balanceOf(binaryArgs: StaticArray<u8>): StaticArray<u8> {
const args = new Args(binaryArgs);
Expand Down Expand Up @@ -117,7 +117,7 @@ export function isApprovedForAll(binaryArgs: StaticArray<u8>): StaticArray<u8> {
*
* @param binaryArgs - serialized strings representing the address of the recipient and the tokenId to approve
* @remarks This function is only callable by the owner of the tokenId or an approved operator.
* Indeed, this will be checked by the _approve function of the NFT-internals.
* Indeed, this will be checked by the _approve function of the MRC721-internals.
*
*/
export function approve(binaryArgs: StaticArray<u8>): void {
Expand Down Expand Up @@ -169,8 +169,8 @@ export function transferFrom(binaryArgs: StaticArray<u8>): void {
* @remarks This function is only callable by the owner of the contract.
*
* This function is not part of the ERC721 standard.
* It serves as an example of how to use the NFT-internals functions to implement custom features.
* Here we make use of the _update function from the NFT-internals to mint a new token.
* It serves as an example of how to use the MRC721-internals functions to implement custom features.
* Here we make use of the _update function from the MRC721-internals to mint a new token.
* Indeed, by calling _update with a non-existing tokenId, we are creating a new token.
*
* We also make sure that the mint feature is only callable by the owner of the contract
Expand All @@ -192,8 +192,8 @@ export function mint(binaryArgs: StaticArray<u8>): void {
* @param binaryArgs - serialized u256 representing the tokenId to burn
*
* @remarks This function is not part of the ERC721 standard.
* It serves as an example of how to use the NFT-internals functions to implement custom features.
* Here we make use of the _update function from the NFT-internals to burn a token.
* It serves as an example of how to use the MRC721-internals functions to implement custom features.
* Here we make use of the _update function from the MRC721-internals to burn a token.
* Indeed, by calling _update with the zero address as a recipient, we are burning the token.
*
* We also made sure that the burn feature is only callable by the owner of the token or an approved operator.
Expand All @@ -211,7 +211,7 @@ export function burn(binaryArgs: StaticArray<u8>): void {
/**
* Here we re-export the ownerAddress function from the ownership file.
* This will allow the outside world to check the owner of the contract.
* However we do not re-export any function from the NFT-internals file.
* This is because the NFT-internals functions are not supposed to be called directly by the outside world.
* However we do not re-export any function from the MRC721-internals file.
* This is because the MRC721-internals functions are not supposed to be called directly by the outside world.
*/
export { ownerAddress } from '../utils/ownership';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file provides internal functions to support token enumeration functionality for the NFT contract on Massa.
* This file provides internal functions to support token enumeration functionality for the MRC721 contract on Massa.
* It utilizes key prefix querying to retrieve all token IDs and tokens owned by specific addresses
* in the datastore without maintaining explicit indices.
*/
Expand All @@ -18,12 +18,12 @@ export const TOTAL_SUPPLY_KEY: StaticArray<u8> = stringToBytes('totalSupply');
export const OWNED_TOKENS_KEY: StaticArray<u8> = stringToBytes('ownedTokens');

/**
* Constructs a new NFT contract.
* Constructs a new MRC721 contract.
* @param binaryArgs - the binary arguments name and symbol
*
* @remarks This function shouldn't be directly exported by the implementation contract.
* It is meant to be called by the constructor of the implementation contract.
* Please check the NFTEnumerable-example.ts file for an example of how to use this function.
* Please check the MRC721Enumerable.ts file for an example of how to use this function.
*/
export function _constructor(name: string, symbol: string): void {
_constructorBase(name, symbol);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This is an example of an NFT contract that uses the `NFTEnumerable-internals`
* This is an example of an MRC721 contract that uses the `MRC721Enumerable-internals`
* helper functions to implement enumeration functionality similar to the ERC-721 Enumerable extension.
*
* @remarks
Expand Down Expand Up @@ -46,12 +46,12 @@
* enabling efficient data retrieval.
*
* **This file does two things:**
* 1. It wraps the `NFTEnumerable-internals` functions, manages the deserialization/serialization of the arguments
* 1. It wraps the `MRC721Enumerable-internals` functions, manages the deserialization/serialization of the arguments
* and return values, and exposes them to the outside world.
* 2. It implements some custom features that are not part of the ERC-721 standard,
* such as `mint`, `burn`, or ownership management.
*
* **Important:** The `NFTEnumerable-internals` functions are not supposed to be re-exported by this file.
* **Important:** The `MRC721Enumerable-internals` functions are not supposed to be re-exported by this file.
*/

import { Args, u256ToBytes } from '@massalabs/as-types';
Expand Down

0 comments on commit 7fe25b0

Please sign in to comment.