EOSIO3.0智能合约使用指南

EOSIO3.0使用指南:

 

1、运行本地节点:

nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::account_history_api_plugin(/data/eos/build/programs/nodeos执行命令)

 

 

2、Ctrl+ct 停掉之后修改运行nodeos节点所创建的config.ini 文件。修改以下几个点,enable-stale-production,producer-name,plugin

cd ~/.local/share/eosio/nodeos/config

vi config.ini

# Enable production on a stale chain, since a single-node test chain is pretty much always stale  

enable-stale-production = true  

# Enable block production with the testnet producers  

producer-name = eosio  

# Load the block producer plugin, so you can produce blocks  

plugin = eosio::producer_plugin  

# Wallet plugin  

plugin = eosio::wallet_api_plugin  

# As well as API and HTTP plugins  

plugin = eosio::chain_api_plugin  

plugin = eosio::http_plugin  

# This will be used by the validation step below, to view account history  

plugin = eosio::account_history_api_plugin

 

修改为那之后再次启动节点

 

注意:以下命令都是在/data/eos/build/programs/cleos目录下执行的

 

3、创建钱包

./cleos wallet create -n yan

所有创建的钱包保存在:/root/.local/share/eosio/nodeos/data文件夹下面

 

 

4、为eosio帐号部署合约(只在创建原始账户的时候执行一次,在创建普通账户是跳过

./cleos set contract eosio ../../contracts/eosio.bios -p eosio

 

 

5、创建2个key,导入key的私钥。

./cleos create key

./cleos create key

./cleos wallet import -n yan 5KUsktm49TWoRrxbxBJPj23VQ4AkiMt1QqeJASxc71Xj683t1kS

./cleos wallet import -n yan 5JgG31BP6kv17cUixgqTJx7RApojpsYwpVHKKeVKmju6f78nvpi

 

 

6、根据生成的公钥,创建帐号。

./cleos create account eosio account1 EOS87bUSc4j3g8cJKJeCnCrJ168b5WGXRegxSzrtfJ4DWdXGdsBgj EOS5L4dbqvGq2zwwAm8x9AiqCPmxmd9ithybBaVQ5Du9QV7RB4s3b

 

查看当前账户信息

./cleos get account account1

 

7、检测,并部署合约

./cleos get code account1

./cleos set contract account1 ../../contracts/currency/

 

 

8、创建货币,发行货币

./cleos push action account1 create '{"issuer":"account1","maximum_supply":"210000000.0000 CUR","can_freeze":"0","can_recall":"0","can_whitelist":"0"}' --permission account1@active

 

./cleos push action account1 issue '{"to":"account1","quantity":"210000000.0000 CUR","memo":""}' --permission account1@active

 

查看当前账户

./cleos get table account1 account1 accounts

 

 

9、转账并查看账户

./cleos push action account1 transfer '{"from":"account1","to":"eosio","quantity":"200.0000 CUR","memo":"my first transfer"}' --permission account1@active

 

 

 

其他一些命令:

 

也可以使用--password参数后跟主密码来跳过提示,但这会导致您的主密码在控制台历史记录中可见

cleos wallet unlock -n wallet_name --password password

 

锁定钱包

cleso wallet lock_all

 

解锁钱包

cleos wallet lock -n wallet_name

 

 参考教程:

https://github.com/EOSIO/eos/wiki/Tutorial-Comprehensive-Accounts-and-Wallets

 

 

1、玩过EOS的都知道,EOS本身更新迭代非常之快,所以有些知识点可能与最新版有所出入,希望小伙伴理解!此文档适用于EOS-v1.0.5以上版本和v1.1.x版本,目前的v1.2.x可能会有极少部分出入,比如eosiocpp工具看更新说明再不用安装的状态下就能使用,目前还未测试。有兴趣的小伙伴可以留言交流。 2、当前文档目录结构介绍: #思考研究问题 1、如何保证EOS中发布的智能合约不被随意篡改? #玩转EOS智能合约代码 #玩转客户端cleos 1、先玩转与智能合约相关的操作 #使用eosiocpp工具编译智能合约生成abi文件和wast文件 #编译合约(无法通过) #安装build/programs下工具 #重新编译合约 #部署合约账户 #购买RAM #测试调用部署的合约 #更新\升级已经部署过的智能合约(相对空的合约) #更新添加新的函数接口(action)合约 #有关require_auth的合约测试 2、玩转智能合约与数据库相关操作 #参考资料 #持久化API (Multi-Index) 1、一般来讲,对数据库的操作无外乎增删改查 2、表结构示例详解 3、Multi_index定义,建立数据表 4、实例化multi_index 5、操作数据,增删改查 #玩转table表 1、Table表producers 2、Table表global 3、Table表voters 4、Table表rammarket (获取RAM实时价格) 5、Table表refunds (查看账户退款信息) 6、Table表namebids (罗列参与竞拍的账户信息) 3、启动nodeos节点出现脏数据 4、查看账户抵押资产,抵押token,赎回token #查看账户余额(可用余额) #查看SYS货币信息,eosio.token是经营货币的合约 #查看公钥对应账户 #查看子账户(控制账户) #查看账户信息 #查看账户抵押信息 #钱不够那就转账,随便耍 #get transaction无结果了解一下 #卖出RAM(卖给系统账户eosio.ram),字节bytes #抵押token获取CPU和net资源 #赎回抵押token,默认三天后到账,执行后可查看账户状态
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值