Coder Social home page Coder Social logo

cryptolions / simpleassets Goto Github PK

View Code? Open in Web Editor NEW
111.0 12.0 65.0 950 KB

A simple standard for digital assets (both fungible and NFTs - non-fungible tokens) for EOSIO blockchains

License: GNU Lesser General Public License v2.1

CMake 1.99% Shell 39.40% C++ 58.61%

simpleassets's Introduction

SimpleAssets

document version 17 March 2021

Scope:

  1. Introduction
  2. Contract actions
  3. Data Structures
  4. EXAMPLES: how to use Simple Assets in smart contracts
  5. AuthorReg
  6. ChangeLog

Introduction

A simple standard for digital assets on EOSIO blockchains: Non-Fungible Tokens (NFTs), Fungible Tokens (FTs), and Non-Transferable Tokens (NTTs).
by CryptoLions

中文翻译: https://github.com/CryptoLions/SimpleAssets/blob/master/README_ZH.md
한국어 번역: https://github.com/CryptoLions/SimpleAssets/blob/master/README_KR.md
Español: https://github.com/CryptoLions/SimpleAssets/blob/master/README_ES.md

WARNING The minimum dependency on eosio.cdt is now v1.6.3.


Use Simple Assets by making calls to the Simple Assets contract. It's like a Dapp for Dapps.

Jungle Testnet: simpleassets

EOS: simpleassets
WAX: simpleassets
MEETONE: smplassets.m
TELOS: simpleassets
PROTON: simpleassets
EUROPECHAIN: simpleassets

Simple Assets is a separate contract which other Dapps can call to manage their digital assets. This serves as an additional guarantee to users of the Dapp that the ownership of assets is managed by a reputable outside authority, and that once created, the Dapp can only manage the asset's mdata. All the ownership-related functionality exists outside the game.

Related: understanding ownership authority.

To post information about your NFTs to third-party marketplaces, use the authorreg action.

Alternatively, dapps can Deploy their own copy of Simple Assets and make modifications to have greater control of functionality, however this may compromise compatibility with wallets and other EOSIO infrastructure. Before deploying, Simple Assets should be modified to prevent anyone from making assets.


Resources

web: http://simpleassets.io
Git: https://github.com/CryptoLions/SimpleAssets
Telegram: https://t.me/simpleassets

Intro & Demos: https://medium.com/@cryptolions/introducing-simple-assets-b4e17caafaa4

(important for developers) A detailed description of each action parameter can be found here:
https://github.com/CryptoLions/SimpleAssets/blob/master/include/SimpleAssets.hpp

Events Receiver Example for authors: https://github.com/CryptoLions/SimpleAssets-EventReceiverExample


Author RAM Payer

NFT authors can enable Author RAM Payer for some or all of their NFTs, and pay for all the RAM associated with transfers so that users don't have to.

Read more about Author RAM Payer


Token Types

Non-Fungible Tokens (FTs)

NFTs are the most common type of digital assets. They are used to express unique tokens.

NFT Structure

Simple Asset NFTs are divided into mdata (data which the author can update at any time, regardless of ownership), and idata (data which is set upon the NFT's creation and can never be updated).

Both are stringified JSONs. For example: {\"key1\":\"some-string\", \"key2\":5}

Category is an optional field that lets you group your NFTs for convenience. Category names must be less than or equal to 12 characters (a-z, 1-5).

Offer/Claim versus Transfer - If you transfer an NFT, the sender pays for RAM. As an alternative, you can simply offer the NFT, and the user claiming will pay for their RAM. (Note: We've deployed an Author RAM Payer feature that allows NFT authors to pay for all the RAM of their NFTs.)

RAM usage

RAM usage for NFTs depends on how much data is stored in the idata and mdata fields. If they both empty, each NFT takes up 276 bytes.

Each symbol in idata and mdata is +1 byte.

Fungible Tokens (FTs)

Dapps which need Fungible tokens should decide between using the standard eosio.token contract, and the Simple Assets contract. Here are the differences:

In Simple Assets,

(Note: Fungible Tokens also have offer/claim functionality as an alternative to transfers. For FTs, the only time the sender would pay for RAM would be if the receiver never before held those FTs. It uses approximately 300 bytes to create the FT table.)

Non-Transferrable Tokens (NTTs)

The two most likely use cases for NTTs are

  • licenses which can be granted to an account, but not transfered.
  • prizes and awards given to a particular account.

The reasons for using NTTs are:

  • the NTTs appearing in third party asset explorers.
  • some functionality is handled by Simple Assets.

More on NTTs: https://medium.com/@cryptolions/introducing-non-transferable-tokens-ntts-2f1a532bf170


Contract actions

A description of each parameter can be found here:
https://github.com/CryptoLions/SimpleAssets/blob/master/include/SimpleAssets.hpp

authorreg		( name author, string dappinfo, string fieldtypes, string priorityimg )
authorupdate		( name author, string dappinfo, string fieldtypes, string priorityimg )
setarampayer		( name author, name category, bool usearam ) 


 # -- For Non-Fungible Tokens (NFTs)---
 
 create			(author, category, owner, idata, mdata, requireсlaim)  
 update			(author, owner, assetid, mdata)  
 transfer		(from, to , [assetid1,..,assetidn], memo)  
 burn			(owner, [assetid1,..,assetidn], memo)  
 
 offer			(owner, newowner, [assetid1,..,assetidn], memo)  
 canceloffer		(owner, [assetid1,..,assetidn])  
 claim			(claimer, [assetid1,..,assetidn])  
  
 delegate		(owner, to, [assetid1,..,assetidn], period, redelegate, memo)  
 undelegate		(owner, [assetid1,..,assetidn])  
 delegatemore		(owner, assetid, period)  
 
 attach			(owner, assetidc, [assetid1,..,assetidn])
 detach			(owner, assetidc, [assetid1,..,assetidn])
 
 attachf		(owner, author, quantity, assetidc)
 detachf		(owner, author, quantity, assetidc)
 
 mdadd			(author, data)
 mdupdate		(id, author, data) 
 mdremove		(id)
 mdaddlog		(id, author, data)

 # -- For Fungible Tokens (FTs) ---
 
 createf		(author, maximum_supply, authorctrl, data)
 updatef		(author, sym, data)
 issuef			(to, author, quantity, memo)
 transferf		(from, to, author, quantity, memo)
 burnf			(from, author, quantity, memo)

 offerf			(owner, newowner, author, quantity, memo)
 cancelofferf		(owner, [ftofferid1,...,ftofferidn])
 claimf			(claimer, [ftofferid1,...,ftofferidn])

 openf			(owner, author, symbol, ram_payer)
 closef			(owner, author, symbol)
 
 # -- For Non-Transferable Tokens (NTTs) ---

 createntt		(author, category, owner, idata, mdata, requireсlaim)  
 updatentt		(author, owner, assetid, mdata)  
 burnntt		(owner, [assetid1,..,assetidn], memo)  
 claimntt		(claimer, [assetid1,..,assetidn])  

Data Structures

Assets

sasset {  
	uint64_t	id; 		// asset id used for transfer and search;  
	name		owner;  	// asset owner (mutable - by owner!!!);  
	name		author;		// asset author (game contract, immutable);  
	name		category;	// asset category, chosen by author, immutable;  
	string		idata;		// immutable assets data. Can be stringified JSON (recommended) 
					// or just sha256 string;  
	string		mdata;		// mutable assets data, added on creation or asset update by author. Can be  
					// stringified JSON (recommended) or just sha256 string;  
					// using a format other than stringified JSON will not interfere with 
					// simple asset functionality, but will harm compatibility with third party
					// explorers attempting to diplay the asset

	sasset[]	container;	// other NFTs attached to this asset
	account[]	containerf;	// FTs attached to this asset
}  

To help third party asset explorers, we recommend including the following fields in idata or mdata: name (text) img (url to image file)

Offers

offers {  
	uint64_t	assetid;	// asset id offered for claim ; 
	name		owner;		// asset owner;  
	name		offeredto;	// who can claim this asset ; 
	uint64_t	cdate;		// offer create date;  
}  

Authors

authors {
        name    author;                 // assets author, who will be able to create and update assets;

        string  dappinfo;               // stringified JSON. Recommendations to include:
                                        // name - name of the application
                                        // company - name of the company
                                        // logo - url to image
                                        // url - url to the game's websites
                                        // info - short description of application
                                        // defaultfee - 100x the % fee you'd like to collect from marketplaces. (for 2%, 200)

        string  fieldtypes;             // data (json) schema to tell third-party markets how to display each NFT field.
                                        // key: state values, where key is the key from mdata or idata;
                                        // recommended values:

                                        // txt    | default type
                                        // url    | show as clickable URL
                                        // img    | link to img file
                                        // webgl  | link to webgl file
                                        // mp3    | link to mp3 file
                                        // video  | link to video file
                                        // hide   | do not show
                                        // imgb   | image as string in binary format
                                        // webglb | webgl binary
                                        // mp3b   | mp3 binary
                                        // videob | video binary
                                        //

        string  priorityimg;            // Specifies primary image field for categories of NFTs.
                                        //
                                        // This is used when you want your NFTs primary image to be something other
                                        // than a URL to an image field specified in the field img.  It also allows you to
                                        // create categories of NFTs with different primary image fields.
                                        //
                                        // data is a strigified json.
                                        // key: NFT categories.
                                        // value: a field from idata or mdata to be used as the primary image for
                                        // all NFTs of that category.

}

Delegates

delegates{  
	uint64_t	assetid;		// asset id offered for claim;  
	name		owner;			// asset owner;  
	name		delegatedto;		// who can claim this asset;  
	uint64_t	cdate;			// offer create date;   
	uint64_t	period;			// Time in seconds that the asset will be lent. Lender cannot undelegate until 
						// the period expires, however the receiver can transfer back at any time.
	bool 		redelegate;		// redelegate is allow more redelegate for to account or not.
	string		memo;			// memo from action parameters. Max 64 length.

}  

Currency Stats (Fungible Token)

stat {  
	asset		supply;		// Tokens supply 
	asset		max_supply;	// Max token supply
	name		issuer;		// Fungible token author
	uint64_t	id;		// Unique ID for this token
	bool		authorctrl;	// if true(1) allow token author (and not just owner) to burn and transfer.
	string		data;		// stringified json. recommended keys to include: `img`, `name`
}

Account (Fungible Token)

accounts {  
	uint64_t	id;		// token id, from stat table
	name		author;		// token author
	asset		balance;	// token balance
}  
offerfs {
	uint64_t	id;		// id of the offer for claim (increments automatically) 
	name		author;		// ft author
	name		owner;		// ft owner
	asset		quantity;	// quantity
	name		offeredto;	// account which can claim the offer
	uint64_t	cdate;		// offer creation date
}

NTT

snttassets {  
	uint64_t	id; 		// NTT id used for claim or burn;  
	name		owner;  	// asset owner (mutable - by owner!!!);  
	name		author;		// asset author (game contract, immutable);  
	name		category;	// asset category, chosen by author, immutable;  
	string		idata;		// immutable assets data. Can be stringified JSON (recommended) 
					// or just sha256 string;  
	string		mdata;		// mutable assets data, added on creation or asset update by author. Can be  
					// stringified JSON (recommended) or just sha256 string;  
					// using a format other than stringified JSON will not interfere with 
					// simple asset functionality, but will harm compatibility with third party
					// explorers attempting to diplay the asset
}  
nttoffers {
	uint64_t	id;		// id of the offer for claim (increments automatically) 
	name		author;		// ntt author
	name		owner;		// ntt owner
	name		offeredto;	// account who can claim the offer
	uint64_t	cdate;		// offer creation date
}

More Data

moredata{
	uint64_t		id;	// id of the more data 
	name			author;	// author of the more data 
	string			data;	// more data. recommended format: strigified JSON
}

Author RAM Payer

sarampayer{
      uint64_t 			id;
      name    			author;
      name    			category;
      bool    			usearam;
      uint64_t  		from_id;

      auto primary_key() const {
        return id;
      }

      uint64_t by_author() const {
        return author.value;
      }
    };

EXAMPLES: how to use Simple Assets in smart contracts

Creating Asset and transfer to owner account ownerowner22:

name SIMPLEASSETSCONTRACT = "simpleassets"_n;

name author = get_self();
name category = "weapon"_n;
name owner = "ownerowner22"_n;
string idata = "{\"power\": 10, \"speed\": 2.2, \"name\": \"Magic Sword\" }";
string mdata = "{\"color\": \"bluegold\", \"level\": 3, \"stamina\": 5, \"img\": \"https://bit.ly/2MYh8EA\" }";

action createAsset = action(
	permission_level{author, "active"_n},
	SIMPLEASSETSCONTRACT,
	"create"_n,
	std::make_tuple( author, category, owner, idata, mdata,	0 )
);
createAsset.send();	

Creating Asset with requireclaim option for ownerowner22:

name SIMPLEASSETSCONTRACT = "simpleassets"_n;

name author = get_self();
name category = "balls"_n;
name owner = "ownerowner22"_n;
string idata = "{\"radius\": 2, \"weigh\": 5, \"material\": \"rubber\", \"name\": \"Baseball\" }";
string mdata = "{\"color\": \"white\", \"decay\": 99, \"img\": \"https://i.imgur.com/QoTcosp.png\" }";


action createAsset = action(
	permission_level{author, "active"_n},
	SIMPLEASSETSCONTRACT,
	"create"_n,
	std::make_tuple( author, category, owner, idata, mdata, 1 )
);
createAsset.send();	

Search asset and get assets info

  1. Please add in your hpp file info about assets structure
TABLE account {
	uint64_t	id;
	name		author;
	asset		balance;

	uint64_t primary_key()const { 
		return id;
	}
};
typedef eosio::multi_index< "accounts"_n, account > accounts;

TABLE sasset {
	uint64_t		id;
	name			owner;
	name			author;
	name			category;
	string			idata;
	string			mdata;
	std::vector<sasset>	container;
	std::vector<account>	containerf;

			
	auto primary_key() const {
		return id;
	}

	uint64_t by_author() const {
		return author.value;
	}
};

typedef eosio::multi_index< "sassets"_n, sasset, 		
		eosio::indexed_by< "author"_n, eosio::const_mem_fun<sasset, uint64_t, &sasset::by_author> >
> sassets;
  1. Searching and using info
name SIMPLEASSETSCONTRACT = "simpleassets"_n;
name author = get_self();
name owner = "lioninjungle"_n;

uint64_t assetid = 100000000000187

sassets assets(SIMPLEASSETSCONTRACT, owner.value);
auto idx = assets.find(assetid);

check(idx != assets.end(), "Asset not found or not yours");

check (idx->author == author, "Asset is not from this author");

auto idata = json::parse(idx->idata);  // for parsing json here is used nlohmann lib
auto mdata = json::parse(idx->mdata);  // https://github.com/nlohmann/json

check(mdata["cd"] < now(), "Not ready yet for usage");

Update Asset

name SIMPLEASSETSCONTRACT = "simpleassets"_n;

auto mdata = json::parse(idxp->mdata);
mdata["cd"] = now() + 84600;

name author = get_self();
name owner = "ownerowner22"_n;
uint64_t assetid = 100000000000187;

action saUpdate = action(
	permission_level{author, "active"_n},
	SIMPLEASSETSCONTRACT,
	"update"_n,
	std::make_tuple(author, owner, assetid, mdata.dump())
);
saUpdate.send();

Transfer one Asset

name SIMPLEASSETSCONTRACT = "simpleassets"_n;

name author = get_self();
name from = "lioninjungle"_n;
name to = "ohtigertiger"_n;

uint64_t assetid = 100000000000187;

std::vector<uint64_t> assetids;
assetids.push_back(assetid);

string memo = "Transfer one asset";

action saTransfer = action(
	permission_level{from, "active"_n},
	SIMPLEASSETSCONTRACT,
	"transfer"_n,
	std::make_tuple(from, to, assetids, memo)
);
saTransfer.send();

Transfer two Asset to same receiver with same memo

name SIMPLEASSETSCONTRACT = "simpleassets"_n;

name author = get_self();
name from = "lioninjungle"_n;
name to = "ohtigertiger"_n;

uint64_t assetid1 = 100000000000187;
uint64_t assetid2 = 100000000000188;

std::vector<uint64_t> assetids;
assetids.push_back(assetid1);
assetids.push_back(assetid2);

string memo = "Transfer two asset"

action saTransfer = action(
	permission_level{from, "active"_n},
	SIMPLEASSETSCONTRACT,
	"transfer"_n,
	std::make_tuple(from, to, assetids, memo)
);
saTransfer.send();

Burn Assets

name SIMPLEASSETSCONTRACT = "simpleassets"_n;

name owner = "lioninjungle"_n;
uint64_t assetid1 = 100000000000187;
uint64_t assetid2 = 100000000000188;

std::vector<uint64_t> assetids;
assetids.push_back(assetid1);
assetids.push_back(assetid2);

string memo = "Transfer two asset"

action saBurn = action(
	permission_level{owner, "active"_n},
	SIMPLEASSETSCONTRACT,
	"transfer"_n,
	std::make_tuple(owner, assetids, memo)
);
saBurn.send();

issuef (fungible) issue created token

name SIMPLEASSETSCONTRACT = "simpleassets"_n;

asset wood;
wood.amount = 100;
wood.symbol = symbol("WOOD", 0);

name author = get_self();
name to = "lioninjungle"_n;

std::string memo = "WOOD faucet";
action saRes1 = action(
	permission_level{author, "active"_n},
	SIMPLEASSETSCONTRACT,
	"issuef"_n,
	std::make_tuple(to, author, wood, memo)
);
saRes1.send();

transferf (fungible) by author if authorctrl is enabled

name SIMPLEASSETSCONTRACT = "simpleassets"_n;

asset wood;
wood.amount = 20;
wood.symbol = symbol("WOOD", 0);

name from = "lioninjungle"_n;
name to = get_self();
name author = get_self();

std::string memo = "best WOOD";
action saRes1 = action(
	permission_level{from, "active"_n},
	SIMPLEASSETSCONTRACT,
	"transferf"_n,
	std::make_tuple(from, to, author, wood, memo)
);
saRes1.send();

burnf (fungible) by author if authorctrl is enabled

name SIMPLEASSETSCONTRACT = "simpleassets"_n;

asset wood;
wood.amount = 20;
wood.symbol = symbol("WOOD", 0);

name author = get_self();
name from = "lioninjungle"_n;

std::string memo = "WOOD for oven";
action saRes1 = action(
	permission_level{author, "active"_n},
	SIMPLEASSETSCONTRACT,
	"burnf"_n,
	std::make_tuple(from, author, wood, memo)
);
saRes1.send();

AuthorReg

authorreg action

Authors can register in the authorreg table to communicate with third party asset explorers, wallets, and marketplaces.

ACTION authorreg( name author, string dappinfo, string fieldtypes, string priorityimg );

@param author is author's account who will create assets.

@param dappinfo is stringified JSON. Recommendations to include: name - name of the application
company - name of the company
logo - url to image
url - url to the game's websites
info - short description of application
defaultfee - 100x the % fee you'd like to collect from marketplaces. (for 2%, 200)

@param fieldtypes is stringified JSON with key:state values, where key is key from mdata or idata and state indicates recommended way of displaying the field. For the latest recommended values, please see https://github.com/CryptoLions/SimpleAssets/blob/master/include/SimpleAssets.hpp.

@param priorityimg is JSON which assosiates an NFT category with the field name from idata or mdata that specifies the main image field for that category of NFTs. This is probably a rare use case and can be left blank. If you wanted a category of NFTs to have a main image field other than img, you'd use "CATEGORY":"otherfieldname". Most likely use case is if you wanted webgls or some other format to be the main image.

Cleos examples of authorreg and authorupdate

authorreg

./cleos.sh.jungle push action simpleassets authorreg '["ilovekolobok", "{\"name\": \"Kolobok Breeding Game\", \"company\": \"CryptoLions\", \"info\": \"Breed your Kolobok\", \"logo\": \"https://imgs.cryptolions.io/logo_256.png\", \"url\": \"https://kolobok.io\", \"defaultfee\":200}", "{\"bdate\":\"timestamp\"},{\"cd\":\"timestamp\"},{\"img\":\"img\"},{\"st\":\"hide\"},{\"url\":\"url\"}", "{\"kolobok\":\"img\"},{\"*\":\"img\"}" ]' -p ilovekolobok

authorupdate

./cleos.sh.jungle push action simpleassets authorupdate '["ilovekolobok", "{\"name\": \"Kolobok Breeding Game\", \"company\": \"CryptoLions\", \"info\": \"Breed your Kolobok\", \"logo\": \"https://imgs.cryptolions.io/logo_256.png\", \"url\": \"https://kolobok.io\", \"defaultfee\":200}", "{\"bdate\":\"timestamp\"},{\"cd\":\"timestamp\"},{\"img\":\"img\"},{\"st\":\"hide\"},{\"url\":\"url\"}", "{\"kolobok\":\"img\"},{\"*\":\"img\"}" ]' -p ilovekolobok

Change Logs

Change Log v1.6.1

  • support for token-back NFT contract
  • Changed map structure type to vector in saeclaim and saechautor log actions
  • Code refactoring
  • Typo fixed
  • Added new developers function: sa_time_to_wait

Change Log v1.6.0

  • Added author ram payer option
  • Added actions setarampayer, delarampayer
  • detach and detachf for author only
  • Memo increased to 512
  • Code improvement

Change Log v1.5.2

Change Log v1.5.1

  • Added burnlog, burnflog, burnnttlog added
  • Added restriction for burning asset with assets attached in container
  • Added restriction to attach to delegated assets
  • Code improvement
  • SAE notification temporary disabled

Change Log v1.5.0

  • Added possibility to include SimpleAssets.hpp into other projects. This helps developers to easily integrate Simple Assets into other contracts.
  • Added developers function sa_getnextid to easily get id of newly created assets.
  • Added more data functionality (actions mdremove, mdupdate, mdaddlog, mdadd). This offers a Simple Asset table which can store extra or repeating information for NFTs, and keep RAM usage to a minimum.

Change Log v1.4.1

  • Renamed fields and actions in Author Registration for better larity regauthor -> authorreg
    data -> dappinfo
    stemplate -> fieldtypes
    imgpriority -> priorityimg
  • Added Author Registration documentation to readme

Change Log v1.4.0

  • re-delegate assets. (lender of assets can allow them to be re-lent)
  • New parameter bool redelegate added in delegate action, which allows asset re-delegation.
  • New field bool redelegate added in table delegates => require migration in case of self- deployed contract !!!
  • In undelegate action parameter from was removed. (identity of borrower is available in the delegates table)
  • Fixed transfer of empty assets array
  • Error messages improved for clarity
  • Code refactoring

Change Log v1.3.0

  • Upgrade work with latest Contract Development Toolkit (CDT v1.6.3).
    (Resolves this compilation issue)
  • minor code refactoring.

Change Log v1.2.0

  • NON TRANSFERRABLE TOKENS (NTTs) - new tables: snttassets and nttoffers
  • new NTT actions: createntt, createnttlog, claimntt, updatentt, burnntt
  • delegatemore action fix (thanks to cc32d9)
  • ricardian contracts updated.
  • external tests for NTT logic added.

Change Log v1.1.3

  • ricardian contracts updated.
  • fungible token offer issue fix

Change Log v1.1.2

  • added string imgpriority field in sauthor table and to regauthor and authorupdate actions
  • IMPORTANT: Self-deployed instances of Simple Assets may need to migrate the regauthor table (if used).

Change Log v1.1.1

  • optimized claim/transfer/burn functionality
  • Memo field added to delegates table. (This allows lenders/games to create different classes of borrowed assets - eg. high risk / low risk.) On delegete action, the memo from action parmeter is stored to this new field. max 64 chars length.
  • Added three new unit tests for delegate memo.

Change Log v1.1.0

  • Code refactoring
  • Fixed detaching containerized NFTs for delegated and transferred NFTs.
  • new action delegatemore which allows extending delegate period for borrowed NFT.
  • Added external(bash) unit tests

Change Log v1.0.1

  • new parameter requireclaim in createlog action which is used internaly to create actions history logs.

Change Log v1.0.0

  • Block owner from offering assets to themselves

Change Log v0.4.2

  • format for saeclaim event changed: array of assetids replaced by map <assetid, from>

Change Log v0.4.1

  • added require_recipient(owner) to create action

Change Log v0.4.0

Easily find fungible token information (fungible tokens have scope author):

  • new field author in account table for FT. (makes it easier to find fungible token information)

More fungible token information:

  • new field data in currency_stats table - stringify json which might include keys img, name (recommended for better displaying by markets)
  • new parameter data in createf action
  • new action updatef to change FT data

Offer/claim fungible tokens

  • new table sofferf to use for offer/calim FT
  • new actions offerf, cancelofferf and claimf
  • on closef check if no open offers (internal)

Containerizing assets

  • new fields container and containerf in nft asset structure for attaching and detaching other NFT or FT
  • new actions attach, detach
  • new actions attachf, detachf

misc

  • fields renamed lastid -> lnftid, spare->defid (internal usage) in table global
  • field offeredTo renamed to offeredto in table soffer

Change Log v0.3.2

  • Added memo parameter to action offer;
  • Added memo parameter to action delegate;

Change Log v0.3.1

  • Internal action for NFT createlog added. Used by create action to log assetid so that third party explorers can easily get new asset ids and other information.
  • New singelton table tokenconfigs added. It helps external contracts parse actions and tables correctly (Usefull for decentralized exchanges, marketplaces and other contracts that use multiple tokens). Marketplaces, exchanges and other reliant contracts will be able to view this info using the following code.
     Configs configs("simpleassets"_n, "simpleassets"_n.value);
     configs.get("simpleassets"_n);
    
  • added action updatever. It updates version of this SimpleAstes deployment for 3rd party wallets, marketplaces, etc;
  • New examples for Event notifications: https://github.com/CryptoLions/SimpleAssets-EventReceiverExample

Change Log v0.3.0

  • Added event notifications using deferred transaction. Assets author will receive notification on assets create, transfer, claim or burn. To receive it please add next action to your author contract:
         ACTION saecreate   ( name owner, uint64_t assetid );  
         ACTION saetransfer ( name from, name to, std::vector<uint64_t>& assetids, std::string memo );  
         ACTION saeclaim    ( name account, std::vector<uint64_t>& assetids );  
         ACTION saeburn     ( name account, std::vector<uint64_t>& assetids, std::string memo );  
    
  • untildate parameter changed to period (in seconds) for actions delegate and table sdelegates

Change Log v0.2.0

Added Fungible Token tables and logic using eosio.token contract but with some changes

  • New actions and logic: createf, issuef, transferf, burnf, openf, closef
  • added new tables stat(supply, max_supply, issuer, id) and accounts (id, balance).
  • scope for stats table (info about fungible tokens) changed to author
  • primary index for accounts table is uniq id created on createf action and stored in stats table.
  • added createf action for fungible token with parametr authorctrl to stats table. If true(1) allows token author (and not just owner) to burnf and transferf. Cannot be changed after creation!
  • Ricardian contracts updated
  • more usage examples below

Change Log v0.1.1

Misc

  • sdelagate table structure renamed to sdelegate (typo)
  • create action parameters renamed: requireClaim -> requireclaim
  • assetID action parameter renamed in all actions to assetid

Borrowing Assets

  • sdelegate table - added new field: untildate
  • delegate action added parameters untildate. Action does a simple check if parameter was entered correctly (either zero or in the future).
  • undelegate will not work until untildate (this guarantees a minimum term of the asset loan).
  • allow transfer asset back (return) if its delegated, sooner than untiltime (borrower has option ton return early)

Batch Processing

  • claim action: assetid parameter changed to array of assetsids. Multiple claim logic added.
  • offer action: assetid parameter changed to array of assetsids. Multiple offer logic added.
  • canceloffer action: assetid parameter changed to array of assetsids. Multiple cancelation logic added.
  • transfer action: assetid parameter changed to array of assetsids. Multiple assets transfer logic added.
  • burn action: assetid parameter changed to array of assetsids. Multiple burning logic added.
  • delegate/undelegate action: assetid parameter changed to array of assetsids. Multiple delegation/undelegation logic added.

simpleassets's People

Contributors

ansigroup avatar cc32d9 avatar deniscarriere avatar duncand0nuts avatar rskaskiw avatar she-lviv avatar tigran-gruv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simpleassets's Issues

Storing Metadata off-chain

Currently I see that the standard is storing the metadata as a string which will be a variant in its size from one NFT to another also in many cases that will be a long string if many properties need to be included. Storing the metadata as a JSON document off-chain and only storing the SHA256 digest of the JSON object on-chain (unit8_t data[32]) in addition to adding mdatauri field (string type) to store a string pointing to the actual mdata JSON object stored off-chain. This should be the best way to implement this as it will save on memory needed.

Errors on build.

Hello,
I'm getting error when i run build on latest version of docker cdt.

root@77c505f65599:/home# cd wax-cdt/
root@77c505f65599:/home/wax-cdt# ls
CHANGELOG.md CONTRIBUTING.md LICENSE SimpleAssets build.sh docs examples install.sh modules tests uninstall.sh
CMakeLists.txt Doxyfile README.md build docker eosio_llvm imports libraries scripts tools
root@77c505f65599:/home/wax-cdt# cd SimpleAssets/
root@77c505f65599:/home/wax-cdt/SimpleAssets# ls
CMakeLists.txt LICENSE README.md README_ES.md README_KR.md README_ZH.md build build.sh external_test include ricardian src
root@77c505f65599:/home/wax-cdt/SimpleAssets# ./build.sh
=========== Building SimpleAssets Contract [by CryptoLions.io] ===========

-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Setting up Eosio Wasm Toolchain 1.6.1 at /usr/local/eosio.cdt
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as

cmake_minimum_required(VERSION 3.10)

should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.

-- Configuring done
-- Generating done
-- Build files have been written to: /home/wax-cdt/SimpleAssets/build
Scanning dependencies of target SimpleAssets_project
[ 11%] Creating directories for 'SimpleAssets_project'
[ 22%] No download step for 'SimpleAssets_project'
[ 44%] No patch step for 'SimpleAssets_project'
[ 44%] No update step for 'SimpleAssets_project'
[ 55%] Performing configure step for 'SimpleAssets_project'
-- Setting up Eosio Wasm Toolchain 1.6.1 at /usr/local/eosio.cdt
-- Setting up Eosio Wasm Toolchain 1.6.1 at /usr/local/eosio.cdt
-- The C compiler identification is Clang 7.0.0
-- The CXX compiler identification is Clang 7.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - failed
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - failed
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as

cmake_minimum_required(VERSION 3.10)

should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.

-- Configuring done
CMake Warning (dev) at /usr/local/eosio.cdt/lib/cmake/eosio.cdt/EosioCDTMacros.cmake:12 (add_dependencies):
Policy CMP0046 is not set: Error on non-existent dependency in
add_dependencies. Run "cmake --help-policy CMP0046" for policy details.
Use the cmake_policy command to set the policy and suppress this warning.

The dependency target
"/home/wax-cdt/SimpleAssets/src/../ricardian/SimpleAssets.clauses.md" of
target "SimpleAssets" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:8 (target_ricardian_directory)
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at /usr/local/eosio.cdt/lib/cmake/eosio.cdt/EosioCDTMacros.cmake:12 (add_dependencies):
Policy CMP0046 is not set: Error on non-existent dependency in
add_dependencies. Run "cmake --help-policy CMP0046" for policy details.
add_dependencies. Run "cmake --help-policy CMP0046" for policy details.
Use the cmake_policy command to set the policy and suppress this warning.

The dependency target
"/home/wax-cdt/SimpleAssets/src/../ricardian/SimpleAssets.contracts.md" of
target "SimpleAssets" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:8 (target_ricardian_directory)
This warning is for project developers. Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /home/wax-cdt/SimpleAssets/build/SimpleAssets
[ 66%] Performing build step for 'SimpleAssets_project'
Scanning dependencies of target SimpleAssets
[ 50%] Building CXX object CMakeFiles/SimpleAssets.dir/SimpleAssets.obj
CMakeFiles/SimpleAssets.dir/build.make:62: recipe for target 'CMakeFiles/SimpleAssets.dir/SimpleAssets.obj' failed
make[5]: *** [CMakeFiles/SimpleAssets.dir/SimpleAssets.obj] Segmentation fault
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/SimpleAssets.dir/all' failed
make[4]: *** [CMakeFiles/SimpleAssets.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make[3]: *** [all] Error 2
CMakeFiles/SimpleAssets_project.dir/build.make:111: recipe for target 'SimpleAssets_project-prefix/src/SimpleAssets_project-stamp/SimpleAssets_project-build' failed
make[2]: *** [SimpleAssets_project-prefix/src/SimpleAssets_project-stamp/SimpleAssets_project-build] Error 2
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/SimpleAssets_project.dir/all' failed
make[1]: *** [CMakeFiles/SimpleAssets_project.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

is there an author, category, or global scope for asset tables?

New user here trying to use SimpleAsset NTTs as an affiliation register (account X is a member of group Y). My app would like to query the snttassets table for entries having a certain author:category signature.

BTW I see only the one NTT "test" asset I recently created on the Telos chain. Is anyone else using the NTT function?

Author contract can freeze trading

Apparently the idea (at least according to the specification and SimpleMarket implementation) to transfer author's share of the trade is an eosio.token::transfer(), however, the author being a smart contract, can have a dispatcher which could assert(), making the whole transaction to fail, effectively freezing trading.

And it seems to be a design choice (and wise, if you ask me, since I am a code-is-law guy 😆), that the author should not be able to freeze trading.

There could be a withdrawal mechanism, but then the specification needs to be amended.

I think there should be a specification for a such a mechanism, since author by design is a smart contract (SA is "Dapp for dapps" afterall), which need to support such a mechanism. That's why it should not be arbitrary ad-hoc-mechanism per each exchange.

Long-running issue of occasional mis-assignment of true asset owner

This isn't a reproducable bug in that it seems to happen at random. I have been dealing with it for several months now.

Here's an example of an asset that says it's belonging to currentxchng but it is really owned by klmay.wam

https://wax.simplemarket.io/account/available-assets/asset/100000019082340?locale=en

I've been told this is a sync issue but I'm not sure that explains it very well. I hope this can be resolved. It is in the API that is returning bad data.

Some assets fail to change when read from API on `update` even after successful `update` Tx and table update

Steps to reproduce

Seems to be random. Currently affecting just one of many assets in the category, but was affecting more before when I was running multiple updates from one Tx

Current behavior

NFT updates the mdata as read by in the table, but API ignores changes repeatedly in some NFTs

https://wax.bloks.io/account/simpleassets?loadContract=true&tab=Tables&table=sassets&account=simpleassets&scope=currentxchng&limit=100&lower_bound=100000016932478

Expected Behavior

NFT should update the mdata as read by the Simple Assets API, and the tables.

API call should reflect the table data

Environment
WAX Main net

Additional context
The issue affected more when I was running multiple actions per transaction. Now it is only affecting one (below)

Example of the issue

https://wax.simplemarket.io/account/available-assets/asset/100000016932478

Why? (real question)

I don’t understand what the buzz is about with “non-fungible tokens” . It’s just yet another multi-index table like any others. I understand the “wow” for people who’ve only seen bitcoin where their blockchain was not made for a general purpose use. As you describe in your video, EOSWizards / CrytpoWizards already had that. It’s just another table.

What am I missing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.