with context_expression [as target(s)]:
with-body

这里 context_expression 要返回一个上下文管理器对象。使用with语句后比try catch 节省代码量

这里使用了 with 语句,不管在处理文件过程中是否发生异常,都能保证 with 语句执行完毕后已经关闭了打开的文件句柄。

with open(r'somefileName') as somefile:
for line in somefile:
print line
# ...more code

with context_expression [as target(s)]:
with-body

这里 context_expression 要返回一个上下文管理器对象。使用with语句后比try catch 节省代码量

这里使用了 with 语句,不管在处理文件过程中是否发生异常,都能保证 with 语句执行完毕后已经关闭了打开的文件句柄。

with open(r'somefileName') as somefile:
for line in somefile:
print line
# ...more code

学习 EOS 的相关笔记,为了方便他人阅读,采用中文记录。

安装开发环境

github
Developer Portal

先了解一下必须要知道的几个概念:

  1. nodeos (node + eos = nodeos) eos 节点,产生区块,提供 rpc 服务等
  2. cleos (cli + eos = cleos) 命令行接口
  3. keosd (key + eos = keosd) 负责 wallet 和 key 相关的操作
dedd9507.png
阅读全文 »

official website
GitHub

旨在成为一个完整的,完全记录的跨平台IDE,使用简单的命令行界面,你将能够:

  • 启动私有 EOS testnet。
  • 编译 EOS 智能合约。
  • 通过单元测试运行它。
  • 调整它直到你觉得它准备好了。
  • 在 EOS 上部署它。
  • 跨平台兼容性。

在EOSFactory中,我们使用Python与智能合约进行交互。但是,在内核里,我们的工具集由C++提供支持。

阅读全文 »

official site

Multi Index Tables are a way to cache state and/or data in RAM for fast access. Multi index tables support create, read, update and delete (CRUD) operations,

each smart contract using a multi index table reserves a partition of the RAM cache; access to each partition is controlled using tablename, code and scope.

Multi Index Tables provide a fast to access data store and are a practical way to store data for use in your smart contract. The blockchain records the transactions, but you should use Multi Index Tables to store application data.

阅读全文 »

https://www.eoscanada.com/en/introduction-to-ricardian-contracts

What is a Ricardian Contract

Simply put, Ricardian Contracts are digital documents that define the terms and conditions of an interaction between two or more parties, written in human readable text, which is then cryptographically signed and verified. It would need to be easily readable for both humans and programs, and should aid in providing clarity to any situations that may arise.

programmer walk thru of Ricardian Contract in EOS
Ricardian contracts — legally binding agreements on the blockchain
Smart Contracts — 3 limitations of a self-enforcing agreement
Live Contracts — What’s all the fuss about

创建账户需要消耗RAM。RAM是EOS主网中的内存,用于存储用户在EOS中使用频率高的数据(账户余额、合约状态等)。
当存储账号状态的空间不足,即RAM不足时,转账或部署合约等相关操作就无法执行。

系统合约中提供了买卖RAM 的方法:
buyram
buyrambytes
sellram

虽然可以买卖RAM, 但是系统做了限制, 用户之间不能交易RAM。 另外买卖RAM 各收取0.5%的手续费。

Bancor算法通过智能合约为数字货币提供了持续的流动性。

EOS 帐户权限

EOS每个帐户生成需要两对密匙,这个之前已经说过,每个密匙代表不同的权限。

active 表示帐户的活跃权限,包括转账,投票等权限。
owner 表示帐户的拥有着权限,可以管理用户的所有权限, 代表的是帐户的最高的权限。

目录

查看权限

cleos get account your-account

改变权限

cleos set account permission ${account_name} ${permission} ${JSON} ${permission}

增加权限
删除权限

create account

https://github.com/cryptokylin/CryptoKylin-Testnet/blob/master/README_CN.md

testnet crate account

curl http://faucet.cryptokylin.io/create_account\?astyler12312

{"msg": "succeeded", "keys": {"active_key": {"public": "EOS7Nd75PyMHmCkHGnLKrCqGCAmtEoUm76cGtAJu42mjzSRcxDHaS", "private": "5JviMeLZhp2cm2VbaSMVt5AtCyfGsVPRX23uVDMZNvC1g1iAAUj"}, "owner_key": {"public": "EOS6pMi12iPz1AWFtDJkyJQh7fumxtMUstR1NkUqPAKvv1gcf8GBn", "private": "5JkTiApCcmEvX4s8RK2s4uEciANxM9ZNFGiwnLqW95eZfMPtkWr"}}, "account": "astyler12312"}%

get testnet coin

每一次调用能获得100EOS, 每天最多获得1000个EOS.

curl http://faucet.cryptokylin.io/get_token?astyler12312

查看账户

cleos -u https://api-kylin.eoslaomao.com get account astyler12312

Create a Wallet

cleos wallet create --to-console

cleos will return a password, save this password somewhere as you will likely need it later in the tutorial.

Creating wallet: default
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
“PW5JPmkZk4KoRah6sEMfakhzTxcjpP26D3H2oqqR7FbG1hSA4nVW9”

Open the Wallet

cleos wallet open
cleos wallet list
cleos wallet unlock

Import keys into your wallet

cleos wallet create_key

EOS5QhwGZkS3j47j54VSiSeGkC58PpXUKMnoKwor34EfMihvBABqg

Import the Development Key

Every new EOSIO chain has a default “system” user called “eosio”.

cleos wallet import
5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3

私钥: 5JohqwPMtZkaEbF5rwAk427rQ1jJDPJJaQc4eNcWi8yVnwpNTsC
公钥: EOS76Cw3GN58rjmAUDXSH9qSsk9VpYYLnH7h68KpzcEkzPZifcRd1

测试网账户
eosio public key: EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
eosio private key: 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3

zuowen123123_PrivateKey
5KHZLf2R26fvdKz3nT22PTYjYb9M1jUwcFqagDKKagiNpze9Lis

zuowen123123_PublicKey
EOS8SFR2nmePUrbyGnE4rRd4ZtwTXkTyWuczn25umyMafvx8XbmcJ

list kyes

cleos wallet keys

Start keosd

keosd &