XuperChain
百度超级链使用
超级链环境部署
- 拉取超级链软件包
1
wget https://mirrors.lllcnm.cn/xuper.zip
- 网络环境配置
1
make testnet
- 启动所有节点
1
sh control_all.sh start
- 合约账号创建
1
bin/xchain-cli account new --account 1111111111111112 --fee 1000

- 查询账号信息
1
bin/xchain-cli acl query --account XC1111111111111112@xuper
- 查询账号余额
1
./bin/xchain-cli account balance XC1111111111111112@xuper -H 127.0.0.1:37101
- 更新账户余额
1
bin/xchain-cli transfer --to XC1111111111111112@xuper --amount 1000 --keys data/keys/ -H 127.0.0.1:37101
- 部署solidity合约
编译合约abi bin部署Hello合约1
solc --bin --abi Test.sol -o .
1
2
3
4
5
6
7
8
9
10
11pragma solidity ^0.4.25;
contract Hello {
string name;
function set(string memory _name) public{
name = _name;
}
function get() public view returns(string) {
return name;
}
}调用合约1
./bin/xchain-cli evm deploy --account XC1111111111111121@xuper --cname Hello --fee 2000 Hello.bin --abi Hello.abi
1
2./bin/xchain-cli evm invoke --method set -a '{"name":"hhh"}' Hello --fee 1000
./bin/xchain-cli evm query --method get Hello
java sdk调用
1 |
|
- 目录结构

- controller 类
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32import cn.hutool.core.lang.Dict;
import com.example.xuperchaintest.util.XuperChainUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.io.UnsupportedEncodingException;
import java.util.Map;
public class TestController {
String contractCreator;
String contractName;
XuperChainUtil xuperChainUtil;
public Dict getBlockchainStatus() throws UnsupportedEncodingException {
return xuperChainUtil.getBlockchainStatus();
}
public Dict addUser( Map<String,String> args) {
return xuperChainUtil.invokeContract(contractCreator,contractName,"set",args);
}
public Dict getUser() {
return xuperChainUtil.queryContract(contractCreator,contractName,"get",null);
}
} - 调用set接口

- 调用get接口

Comments
Comment plugin failed to load
Loading comment plugin