- eosio.cdt --- branch: release/1.5.x 或以上
- eosio.contract --- tag: v1.5.2 或以上
add_subdirectory(metadata)
./build.sh
cd build
cleos set contract metadatatptp ./tpaccount -p metadatatptp
设置eosio.code权限:为了让合约可以调用其他合约的action
cleos set account permission metadatatptp active '{"threshold": 1,"keys": [{"key": "EOS66FPKnqfvZYbuMa38Tdb6XMo8PeVFqDwykvyYrj61Y8LbqKxjT ","weight": 1}],"accounts": [{"permission":{"actor":"metadatatptp","permission":"eosio.code"},"weight":1}]}' owner -p metadatatptp
jungle测试网 合约 metadatatptp 节点:https://jungle2.cryptolions.io
transfer(name from, name to, asset quantity, string memo)
update(name account_name,string title,string avatar,string desc,name modifier,string url)
cleos push action eosio.token transfer '["huoyantest11","metadatatptp","0.1000 EOS","huoyantest12"]' -p huoyantest11
cleos push action metadatatptp update '["huoyantest12","火焰神","http://www.huoyan.jpg","这是火焰之家","huoyantest11","\"web\":\"123\""]' -p huoyantest11
cleos push action eosio.token transfer '["huoyantest13","metadatatptp","0.1500 EOS","huoyantest12"]' -p huoyantest13
cleos push action metadatatptp update '["huoyantest12","火焰神13","http://www.huoyan.jpg","这是火焰之家13","huoyantest13","\"web\":\"13\""]' -p huoyantest13
cleos push action eosio.token transfer '["huoyantest12","metadatatptp","0.0750 EOS","huoyantest12"]' -p huoyantest12
cleos push action metadatatptp update '["huoyantest12","火焰神本人","http://www.huoyan.jpg","这是火焰之家本人","huoyantest12","\"web\":\"本人\""]' -p huoyantest12
cleos push action metadatatptp update '["huoyantest12","火焰神本人2","http://www.huoyan.jpg","这是火焰之家本人2","huoyantest12","\"web\":\"本人2\""]' -p huoyantest12
cleos push action metadatatptp addverifier '["chendatony44"]' -p metadatatptp
cleos push action metadatatptp addverifier '["metadatatptp"]' -p metadatatptp
applyverify(name account_name,string memo)
cleos push action metadatatptp applyverify '["huoyantest12","请确认身份"]' -p huoyantest12
verify(name account_name)
cleos push action metadatatptp verify '["huoyantest12","metadatatptp"]' -p metadatatptp
增加黑名单
addblack(name account_name,name verifier)
cleos push action metadatatptp addblack '["huoyantest12""metadatatptp"]' -p metadatatptp
去除黑名单
delblack(name account_name,name verifier)
cleos push action metadatatptp delblack '["huoyantest12""metadatatptp"]' -p metadatatptp
setbymaster(name account_name,string title,string avatar,string desc,string url)
cleos push action metadatatptp setbymaster '["huoyantest12","火焰神本人2","http://www.huoyan.jpg","这是火焰之家本人2","\"web\":\"本人2\""]' -p huoyantest12
cleos get table metadatatptp metadatatptp verifiers
struct [[eosio::table]] accounts {
name account_name;
string title;
string avatar;
string desc;
name modifier;
uint64_t status; //0:初值 1:已支付; 2:已修改; 3:account_name本人已经修改
uint64_t verified;
string url;
asset price;
uint64_t primary_key() const { return account_name.value; }
uint64_t get_price()const {return price.amount; }
uint64_t get_modifier()const {return modifier.value; }
EOSLIB_SERIALIZE(accounts, (account_name)(title)(avatar)(desc)(modifier)(status)(verified)(url)(price))
};
typedef eosio::multi_index<"accounts"_n, accounts,
indexed_by<"price"_n,const_mem_fun<accounts,uint64_t,&accounts::get_price>>, //价格 索引
indexed_by<"modifier"_n,const_mem_fun<accounts,uint64_t,&accounts::get_modifier>>> account_table; //修改者索引
cleos get table metadatatptp metadatatptp accounts
struct [[eosio::table]] investigate {
name account_name;
string memo;
uint64_t propose_time;
uint64_t primary_key() const { return account_name.value; }
uint64_t get_propose_time() const { return propose_time; }
EOSLIB_SERIALIZE(investigate, (account_name)(memo)(propose_time))
};
typedef eosio::multi_index<"investigate"_n, investigate,
indexed_by<"time"_n,const_mem_fun<investigate,uint64_t,&investigate::get_propose_time>>> investigate_table; //发起申请时间索引
cleos get table metadatatptp metadatatptp investigate
struct [[eosio::table]] black {
name black_account;
uint64_t primary_key() const { return black_account.value; }
EOSLIB_SERIALIZE(black, (black_account))
};
cleos get table metadatatptp metadatatptp black
accounts
{
account_name: "chendatony44",
avatar: "https://tp-statics.tokenpocket.pro/website-token/1562040672940-tp-lab.png",
desc: "小明的账号1",
modifier: "chendatony44",
price: "0.1000 EOS",
status: 3,
title: "小明",
url: '{"website":"https://www.baidu.com","telegram":"tokenPocket_en","twitter":"TokenPocket_en","wechat":"TP-robot"}',
verified: 0
}
const CONTRACT_NAME = account.info;
let url = {
website: 'https://www.baidu.com',
telegram: 'tokenPocket_en',
twitter: 'TokenPocket_TP',
wechat: 'TP-robot'
}
let actions = [{
"account": "eosio.token",
"name": "transfer",
"authorization": [{
"actor": 'youraccount',
"permission": 'active'
}],
"data": {
"from": 'youraccount', // 当前账号
"memo": 'itokenpocket', // 需要编辑的账号
"quantity": '0.1000 EOS', // 初始价格为0.1,没增加一次
"to": CONTRACT_NAME // 合约账号
}
}, {
"account": CONTRACT_NAME,
"name": "update",
"authorization": [{
"actor": 'youraccount',
"permission": 'active'
}],
"data": {
"account_name": 'itokenpocket', // 需要编辑的账号
"avatar": 'https://a.com/a.jpg', // 头像图片地址
"desc": '介绍信息',
"modifier": 'youraccount',
"title": 'TokenPocket官方账号', // 名字昵称
"url": JSON.stringify(url)
}
}]