Android app is FindElfi
Thursday, October 3, 2019
6USB smart charger
Application:
This product support smart phones. Iphone, ipad. Bluetooth Speaker, Powerbank. DV. BT Car Kit, Digital camera. Mp3. Mp4. electronic book. all kinds of computers and other 5V output digital products. can meet six people power demands at the same time.
Usage:
Connect the power cord to the USB socket. then light on. According to different output demands choose socket. (From end to top. Sockets are (
USB1 2.1A. USB2 2.1A. USB3 1A, USB4 1A USB5 0.5A,USB6 0.5A
).
Features:
- 6-Port USB charging station can charge 6 devices simultaneously.
- Save several chargers and space.
- 7.2A 30W, fast reliable charge speed.
- Smart IC Technology can intelligently identify your device and offer the current accordingly for that device.
- The Built-in surge protector incorporated to safeguard your USB devices, keeping over-current, over-voltage and short-circuit safely, without risk of overheating or damaging devices.
Product Parameter:
- Size: 66*77*110MM
- Color: grey+white
- Weight: 130g
- Rated power.30W
- Input: AC100V-240V
- Output 5V
packing:
- USB charger 1PCS.
- charger cable 1PCS.
- manual 1PCS.
Saturday, February 24, 2018
Zebi ico
ZEBI AIRDROP LOTTERY: An Airdrop Lottery of ZEBI tokens for all that register via our new “Silver List”
Thursday, February 22, 2018
人为什么要辛苦赚钱
辛苦地赚钱,不是因为多爱钱!
而是这辈子,
不想因为钱和谁低三下四,
也不想因为钱而为难谁;
只希望在父母年老时,
我可以有能力分担;
在孩子需要时,
我不会囊中羞涩。
最近很流行的一段话:“没有钱,
你拿什么维持你的亲情,
稳固你的爱情,联络你的友情,
靠嘴说吗,
别闹了,大家都挺忙的!”
穷在闹市无人问,富在深山有远亲,
不信但看宴中酒,杯杯先敬富贵人,
门前拴着高头马,不是亲来也是亲,
门前放着讨饭棍,亲朋好友不上门,
世上结交需黄金,黄金不多交不深,
有钱有酒多兄弟,急难何曾见一人。
胜者为王败者寇,只重衣官不看人,
三穷三富过到老,十年兴败多少人,
在官三日人问我,离官三日我问人,
近水楼台先得月,向阳花木又逢春,
谁人背后无人说,谁人背后不说人。
现在的人太现实……
不敢倒下,因为身后有孩子!
不敢逃避,因为前面有父母!
不敢生病,因为没有人照顾 !
不敢说累,因为没有人惯着!
不敢偷懒,因为没有人给钱花!
坚强,独立,是唯一的选择!
寂寞的时候放首歌给自己听、
伤心的时候找个角落擦擦眼泪。
告诉自己这都不是事,
时刻提醒自己不能倒下。
一定要坚强!
——致奋斗在路上的自已。
这些话,
现实的伤心,残酷的戳心!
没有理由不前进,没有借口不打拼,
努力到无能为力,拼搏到感动自己,
在阳光下灿烂,在风雨中坚强,
最棒的三个字是,靠自己!
记住了,
别伤了你缺钱时帮助你的人 !
借钱,那滋味真的很痛……
无利息借给你的不是钱,
而是信任,是鼓励…
现在的人都怕:
站着借钱,跪着要债。
钱,
借出去时是感情,
收回来时是仇人。
这年头,
你手头紧的时候,什么最难?
借钱最难!
肯借钱给你的人,
一定是你的贵人;
如今,这样的贵人不多,
遇到了,必须珍惜一辈子。
因为钱花不了一辈子!
帮助你的人,目的只有一个,
那就是希望你能过的更好!!
去珍惜那个舍得给你花钱的人,
不管这个人是亲人,
爱人还是蓝颜红颜,或者朋友,
因为钱对于谁来说,
都是不够花的……
舍得给你花钱的人,
不是因为钱多,
也不是因为他傻,
而是那一刻他觉得你比钱重要……
友不在多,贵在风雨同行。
情不论久,重在有求必应,
所谓情真:
只要你要,只要我有;
只要你需,只要我能。
所谓义重:
不是得意时的花言巧言,
而是关键时刻拉你的那只手!
不要炫耀你的钱,
死了那只是废纸;
不要炫耀你的房,
你去了,那就是别人的窝;
不要炫耀你的车,
你离开了,车钥匙就在别人手里握!
钱永远挣不完,命却是有限的,
拼命可以挣钱,拼钱却不能挣命!
人生最大的错误,
是用健康换取身外之物。
没有任何东西比得上好身体!
人这辈子:
有人舍得给你花钱,
那叫幸福,千万要知足!
有人愿意借给你钱,
那叫资助,千万要记住!
自己能够挣来的钱,
那叫辛苦,千万要满足!
Friday, January 5, 2018
Wednesday, December 6, 2017
区块链开发(三)@
区块链开发(三)编写调试第一个以太坊智能合约@
李赫 2016-09-13 10:02 发布在 技术指南,竞争币 6 17757
一、 智能合约IDE简介
目前以太坊上支持三种语言编写智能合约,
Solidity:类似JavaScript,这是以太坊官方推荐语言,也是最流行的智能合约语言。具体用法参加Solidity文档,地址:https://solidity.readthedocs.io/en/latest/
Serpent:类似Python风格,文档地址:https://github.com/ethereum/wiki/wiki/Serpent
LLL:类似Lisp风格,目前已经被终止了。
可以根据不同的习惯选择不同的高级语言,目前最流行的是Solidity。本文所有的智能合约均为Solidity语言编写。
目前能够编写智能合约的IDE有常见几种:
Mix:是早期以太坊主要的开发IDE,可以支持智能合约和DAPP的编写、调试,部署,全图形化界面,但是随着原创主持人Gavin Wood的离开,慢慢边缘化,最终被停止开发,整个团队转向Remix项目,出于对未来的考虑,不建议学习Mix。
Remix:是原Mix团队的新作品,目前只有简单的Debug功能上线,未来可以重点关注一下。
browser-solidity:该项目是智能合约浏览器版本的开发环境,可以支持在浏览器中直接开发、调试和编译,对于初学者来说,可以快速上手,不需要安装,非常方便,直接访问地址使用:https://ethereum.github.io/browser-solidity/,本文采用此IDE进行开发。
Ethereum Studio:第三方公司开发的企业版智能合约在线IDE,功能强大,免费使用,可以作为企业级开发的一个工具,访问地址:https://live.ether.camp/
Visual Studio 2015:没错,就是微软的VS 2015,微软已经把以太坊的智能合约编写功能整合了,可以看出微软对以太坊的重视。
二、 编写第一个智能合约
1、 智能合约语法学习方法
智能合约的语法和示例可以在Solidity的文档网站http://solidity.readthedocs.io/en/latest/查看,基本上把这些在线文档看完,已经算精通了,剩下的只是实践编写代码。
2、 示例合约代码
首先,我们先给出一个示例代码,后面将以这个代码为例解释说明智能合约的编写和调试。
——————————————————————————————-
contract Votelihe {
struct Candidate {
uint votecount;
string name;
}
struct Voter {
bool voted;
}
mapping(address => Voter) public voters;
Candidate[] public candidates;
function Votelihe() {
candidates.push(Candidate({
name: “lihe”,
votecount: 0
}));
candidates.push(Candidate({
name: “dandan”,
votecount: 0
}));
}
function Vote_candidate(uint8 numCandidate)
{
if(voters[msg.sender].voted ||numCandidate>candidates.length)return;
candidates[numCandidate].votecount+=1;
voters[msg.sender].voted=true;
}
function Getcount() returns(string,uint,string,uint){
return(candidates[0].name,candidates[0].votecount,candidates[1].name,candidates[1].votecount);
}
}
————————————————————————————————–
该代码创建了一个投票程序,对两个候选人lihe和dandan进行投票,每个人只有一次投票的机会,最后反馈lihe和dandan的得票结果。各个函数说明如下:
function Votelihe():构造函数,智能合约只运行一次
function Vote_candidate():对候选人进行投票,每个投票者只能投一票
function Getcount():返回当前候选的得票数
3、 使用IDE编写智能合约
首先我们打开browser-solidity,IDE的主要功能如下:
将示例代码拷贝到左侧的代码编辑框,IDE将自动检测语法错误,并显示在右侧的窗口上,如下图所示:
可以看到,提示有未声明的对象,是在14行的错误,很明显是我一个结构对象candidates误写为candidates2了,修改一下即可校验通过。
注意,在浏览器里编写代码,他是自动保存在本地浏览器缓存里面的,只要清除浏览器缓存,代码不会丢失。
三、调试第一个智能合约
目前browser-solidity有两种常用的调试方式,一个是采用本地虚拟机调试模式,一个是连接到本地的私有链进行调试。
1、 本地虚拟机调试模式
本地虚拟机调试,就是不连接任何一个节点,在内存虚拟出一个以太坊节点进行调试,优点是速度快,配置简单,缺点是因为只是虚拟调试,可能最后放到真正的区块链节点上运行智能合约会和预想的结果不同。
首先在DEBUG环境设置中,选择JavaScript VM以设置本地虚拟调试模式,如下图:
设置成功后,可以在账号状态栏看到可以用的账户列表,如下图
智能合约代码编写好后,点击“Create”按钮部署智能合约到内存中,并进行调试,如果部署成功,会出现智能合约的函数运行按钮和参数输入框,然后就可以调试你的智能合约了,如下图:
运行函数后,会出现相应的交易数据,可以完成整个智能合约调试。
如果想逐步调试智能合约,那么选择小虫子图标,切换到逐步调试界面,即可实现单步运行智能合约,注意这里的单步运行不是指代码而是指智能合约编译后的OPCODE,如下图。
2、 连接到本地私有链调试
连接到本地私有链调试,就是通过RPC接口,连接本地的以太坊节点,实际部署并调试智能合约,缺点是速度较慢,配置复杂,优点是能够真实运行智能合约,最大程度的防止出错,关于私有链的配置,请参考我原先发表的文章《区块链开发(一)搭建基于以太坊的私有链环境》。
首先在DEBUG环境设置中,选择Web3 Provider以设置本地虚拟调试模式,同时默认会给出一个连接地址为http://localhost:8545,如果你配置的私有链RPC端口修改了,记得要改成对应的端口,如下图:
然后,切换到账号状态栏,此时显示的可用账号,应该都是你部署的私有链里面的账号,如果不是,说明没有成功连接私有链。可能的原因有两个,一是私有链提供的端口是用http访问,而browser-solidity的网页访问地址是https,解决的方法就是将browser-solidity访问地址改为http协议的地址即可http://ethereum.github.io/browser-solidity/;二是系统的时间没有和网络同步,使用windows系统自带的时间同步功能同步一下即可。
四、 其他常见智能合约资源
下面一些例子网站去参考一些成熟的代码,方便快速迭代学习,常见的例子网站如下:
https://github.com/ethereum/wiki/wiki/Solidity-Collections
http://ether.fund/contracts/
https://github.com/chriseth/solidity-examples
https://github.com/ethereum/dapp-bin
https://github.com/fivedogit/solidity-baby-steps
http://dapps.ethercasts.com
http://ether.fund/contracts
开发框架常用的有3个:
Truffle:说明书地址http://truffle.readthedocs.io/en/latest/
以太坊目前很流行的开发框架Truffle的说明书,这个框架比较流行。
Dapple:说明书地址http://dapple.readthedocs.io/en/master/
这个开发框架是在gitter chart上看到的,感觉用的人不多,先观察
Meteor:说明书地址https://github.com/ethereum/wiki/wiki/Dapp-using-Meteor
这个开发框架是以太坊官方推荐的,写进了以太坊的官方wiki,值得学习,当然,以太坊官方经常转换方向,以后换别的也没准..
巴比特资讯http://www.8btc.com/ethereum-smart-contract
samrt contact test
开源工具和语言
一、brewMacOS包管理器
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
二、Solidity以太坊智能合约语言
brew install solidity
The GitHub credentials in the macOS keychain may be invalid.
Clear them with:
printf "protocol=https\nhost=github.com\n" | git credential-osxkeychain erase
Or create a personal access token:
https://github.com/settings/tokens/new?scopes=gist,public_repo&description=Homebrew
三、geth运行以太坊节点
liyuechun:Downloads yuechunli$ cd go-ethereum-1.5.9
liyuechun:go-ethereum-1.5.9 yuechunli$ pwd
/Users/liyuechun/Downloads/go-ethereum-1.5.9
liyuechun:go-ethereum-1.5.9 yuechunli$ make geth
建立私链
1. 创建一个文件夹来存储你的私链数据
liyuechun:1015 yuechunli$ mkdir privchain
liyuechun:1015 yuechunli$ pwd
/Users/liyuechun/Desktop/1015
liyuechun:1015 yuechunli$ ls
privchain
liyuechun:1015 yuechunli$
2. 使用geth
来加载
geth --rpc --rpcaddr 127.0.0.1 --rpcport 8545 --dev --datadir privchain
INFO [10-15 03:14:50] IPC endpoint opened: /Users/liyuechun/Desktop/1015/privchain/geth.ipc INFO [10-15 03:14:50] HTTP endpoint opened: http://127.0.0.1:8545
privchain
文件夹里面,你会看到geth
, geth.ipc
, 和 keystore
。liyuechun:1015 yuechunli$ cd privchain/
liyuechun:privchain yuechunli$ ls
geth geth.ipc keystore
liyuechun:privchain yuechunli$
- 保持节点的运行,不要关闭终端,重新打开一个终端,使用
geth attach
连接节点,并且打开geth console
liyuechun:privchain yuechunli$ geth attach ipc:/Users/liyuechun/Desktop/1015/privchain/geth.ipc
Welcome to the Geth JavaScript console!
instance: Geth/v1.7.1-stable-05101641/darwin-amd64/go1.9.1
modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 shh:1.0 txpool:1.0 web3:1.0
>
3. 相关api命令
> personal.listAccounts
[]
>
> personal.newAccount('liyuechun')
"0xb6d7d842e7dc9016fa6900a183b2be26fc90b2d8"
>
liyuechun
是你账户的密码,输入你自己喜欢的密码。> personal.listAccounts
["0xb6d7d842e7dc9016fa6900a183b2be26fc90b2d8"]
>
4. web3命令
> web3.eth.coinbase
"0xb6d7d842e7dc9016fa6900a183b2be26fc90b2d8"
>
5. 编写智能合约代码
pragma solidity ^0.4.4;
contract test {
function multiply(uint a) returns(uint d){
return a * 7;
}
}
6. 获取智能合约字节码和abi
6060604052341561000f57600080fd5b5b60ab8061001e6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063c6888fa114603d575b600080fd5b3415604757600080fd5b605b60048080359060200190919050506071565b6040518082815260200191505060405180910390f35b60006007820290505b9190505600a165627a7a7230582067d7c851e14e862886b6f53dad6825135557fb3a4b691350c94ea5b80605f6770029
{
"contract_name": "test",
"abi": [
{
"constant": false,
"inputs": [
{
"name": "a",
"type": "uint256"
}
],
"name": "multiply",
"outputs": [
{
"name": "d",
"type": "uint256"
}
],
"payable": false,
"type": "function"
}
],
"unlinked_binary": "0x60606040523415600e57600080fd5b5b60978061001d6000396000f300606060405263ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663c6888fa18114603c575b600080fd5b3415604657600080fd5b604f6004356061565b60405190815260200160405180910390f35b600781025b9190505600a165627a7a723058203da73c4161a1751d52899e2da724076a62a935cb5e7ed4b29f7f49560675ab8d0029",
"networks": {},
"schema_version": "0.0.5",
"updated_at": 1508016118593
}
7. 在bejson中转义成字符串
{\"contract_name\":\"test\",\"abi\":[{\"constant\":false,\"inputs\":[{\"name\":\"a\",\"type\":\"uint256\"}],\"name\":\"multiply\",\"outputs\":[{\"name\":\"d\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"}],\"unlinked_binary\":\"0x60606040523415600e57600080fd5b5b60978061001d6000396000f300606060405263ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663c6888fa18114603c575b600080fd5b3415604657600080fd5b604f6004356061565b60405190815260200160405180910390f35b600781025b9190505600a165627a7a723058203da73c4161a1751d52899e2da724076a62a935cb5e7ed4b29f7f49560675ab8d0029\",\"networks\":{},\"schema_version\":\"0.0.5\",\"updated_at\":1508016118593}
7. 通过abi创建合约对象
> var contractInfo = JSON.parse('{\"contract_name\":\"test\",\"abi\":[{\"constant\":false,\"inputs\":[{\"name\":\"a\",\"type\":\"uint256\"}],\"name\":\"multiply\",\"outputs\":[{\"name\":\"d\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"}],\"unlinked_binary\":\"0x60606040523415600e57600080fd5b5b60978061001d6000396000f300606060405263ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663c6888fa18114603c575b600080fd5b3415604657600080fd5b604f6004356061565b60405190815260200160405180910390f35b600781025b9190505600a165627a7a723058203da73c4161a1751d52899e2da724076a62a935cb5e7ed4b29f7f49560675ab8d0029\",\"networks\":{},\"schema_version\":\"0.0.5\",\"updated_at\":1508016118593}')
> myContract = web3.eth.contract(contractInfo.abi)
{
abi: [{
constant: false,
inputs: [{...}],
name: "multiply",
outputs: [{...}],
payable: false,
type: "function"
}],
eth: {
accounts: ["0x2abf46d8b0d940cdeedd55872bc0648add40227d"],
blockNumber: 384,
coinbase: "0x2abf46d8b0d940cdeedd55872bc0648add40227d",
compile: {
lll: function(),
serpent: function(),
solidity: function()
},
defaultAccount: undefined,
defaultBlock: "latest",
gasPrice: 0,
hashrate: 0,
mining: false,
pendingTransactions: [],
protocolVersion: "0x3f",
syncing: false,
call: function(),
contract: function(abi),
estimateGas: function(),
filter: function(fil, callback),
getAccounts: function(callback),
getBalance: function(),
getBlock: function(),
getBlockNumber: function(callback),
getBlockTransactionCount: function(),
getBlockUncleCount: function(),
getCode: function(),
getCoinbase: function(callback),
getCompilers: function(),
getGasPrice: function(callback),
getHashrate: function(callback),
getMining: function(callback),
getPendingTransactions: function(callback),
getProtocolVersion: function(callback),
getRawTransaction: function(),
getRawTransactionFromBlock: function(),
getStorageAt: function(),
getSyncing: function(callback),
getTransaction: function(),
getTransactionCount: function(),
getTransactionFromBlock: function(),
getTransactionReceipt: function(),
getUncle: function(),
getWork: function(),
iban: function(iban),
icapNamereg: function(),
isSyncing: function(callback),
namereg: function(),
resend: function(),
sendIBANTransaction: function(),
sendRawTransaction: function(),
sendTransaction: function(),
sign: function(),
signTransaction: function(),
submitTransaction: function(),
submitWork: function()
},
at: function(address, callback),
getData: function(),
new: function()
}
8. 检查coinbase账号余额
> account1 = web3.eth.coinbase
"0x2abf46d8b0d940cdeedd55872bc0648add40227d"
> web3.eth.getBalance(account1)
0
>
> miner.start();
null
>
miner.stop();
9. 停止挖矿,并且查余额
> miner.start();
null
> miner.stop();
true
> web3.eth.getBalance(account1)
1.152e+21
>
10. 解锁coinbase账号,我们通过coinbase账号来付费部署合约
liyuechun
: 换成你的密码。> personal.unlockAccount(account1, 'liyuechun')
true
>
11. 预估手续费
> bytecode = "6060604052341561000f57600080fd5b5b60ab8061001e6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063c6888fa114603d575b600080fd5b3415604757600080fd5b605b60048080359060200190919050506071565b6040518082815260200191505060405180910390f35b60006007820290505b9190505600a165627a7a7230582067d7c851e14e862886b6f53dad6825135557fb3a4b691350c94ea5b80605f6770029"
"6060604052341561000f57600080fd5b5b60ab8061001e6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063c6888fa114603d575b600080fd5b3415604757600080fd5b605b60048080359060200190919050506071565b6040518082815260200191505060405180910390f35b60006007820290505b9190505600a165627a7a7230582067d7c851e14e862886b6f53dad6825135557fb3a4b691350c94ea5b80605f6770029"
> web3.eth.estimateGas({data: bytecode})
Error: invalid argument 0: json: cannot unmarshal hex string without 0x prefix into Go struct field CallArgs.data of type hexutil.Bytes
at web3.js:3104:20
at web3.js:6191:15
at web3.js:5004:36
at :1:1
> bytecode = "0x6060604052341561000f57600080fd5b5b60ab8061001e6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063c6888fa114603d575b600080fd5b3415604757600080fd5b605b60048080359060200190919050506071565b6040518082815260200191505060405180910390f35b60006007820290505b9190505600a165627a7a7230582067d7c851e14e862886b6f53dad6825135557fb3a4b691350c94ea5b80605f6770029"
"0x6060604052341561000f57600080fd5b5b60ab8061001e6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063c6888fa114603d575b600080fd5b3415604757600080fd5b605b60048080359060200190919050506071565b6040518082815260200191505060405180910390f35b60006007820290505b9190505600a165627a7a7230582067d7c851e14e862886b6f53dad6825135557fb3a4b691350c94ea5b80605f6770029"
> web3.eth.estimateGas({data: bytecode})
98391
>
0x
。手续费大概为98391
wei
。12. 部署合约,为了方便理解,设置一个回调函数
> contractInstance = myContract.new({data: bytecode gas: 1000000, from: account1}, function(e, contract){
if(!e){
if(!contract.address){
console.log("Contract transaction send: Transaction Hash: "+contract.transactionHash+" waiting to be mined...");
}else{
console.log("Contract mined! Address: "+contract.address);
console.log(contract);
}
}else{
console.log(e)
}
})
Contract transaction send: Transaction Hash: 0x5e2aebbf400d71a32e807dc3f11f1053b6ee3b2a81435ed8ace2fa54eebb9f3d waiting to be mined...
{
abi: [{
constant: false,
inputs: [{...}],
name: "multiply",
outputs: [{...}],
payable: false,
type: "function"
}],
address: undefined,
transactionHash: "0x5e2aebbf400d71a32e807dc3f11f1053b6ee3b2a81435ed8ace2fa54eebb9f3d"
}
>
13. 你的合约等待挖矿,开始挖矿,等一会儿,停止
> miner.start()
null
> Contract mined! Address: 0xbf8b24283f2516360d3a4ba1db0df78ae74689db
[object Object]
> miner.stop()
true
>
14. 检查合约是否部署成功
> eth.getCode(contractInstance.address)
"0x60606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063c6888fa114603d575b600080fd5b3415604757600080fd5b605b60048080359060200190919050506071565b6040518082815260200191505060405180910390f35b60006007820290505b9190505600a165627a7a7230582067d7c851e14e862886b6f53dad6825135557fb3a4b691350c94ea5b80605f6770029"
>
15. 调用合约方法
> contractInstance.multiply.call(6)
42
>
call
的原因是因为multiply
函数没有添加constant
。pragma solidity ^0.4.4;
contract test {
function multiply(uint a) returns(uint d){
return a * 7;
}
}