EVM-JRPC调用Vision原生功能
注意事项
1、功能生效版本:ultima1.2.0 预计2022H2
2、合约代码内部调用0x8888888888888888888888888888888888888888不会生效。
3、原生接口调用0x8888888888888888888888888888888888888888不会生效。
介绍
Metamask是以太坊钱包,使用广泛。为了方便用户使用Vision,Vision除了兼容了部分metamask的主要接口外,还兼容了vision的原生功能:
带签名的事务性交易:冻结(光量子/熵/节点质押/社区节点投票),解冻(光量子/熵/节点质押/社区节点投票),提取收益,节点申请,节点信息修改,节点佣金比例修改,proposal创建,proposal审核,proposal删除,账户信息修改
查询类交易:查询收益,查询节点佣金比例,查询维护周期
接口
vision原生交易兼容evm的JRPC接口注意是这两个方法:
eth_sendRawTransaction(为签名交易创建一个新的消息调用交易或合约)
eth_call(立刻执行一个新的消息调用,无需在区块链上创建交易)
其中eth_sendRawTransaction为带签名的事务性交易,eth_call为不带签名的无需上链的查询类交易。
节点连接信息参照:部分兼容以太坊Jrpc API
兼容说明
将底层交易类型按照合约方法及参数方式规范,设定固定合约地址,方法及参数生成abi,调用方式参照合约调用方式,合约地址为固定地址,data为传入的交易方法名及参数
合约地址为:0x8888888888888888888888888888888888888888
合约ABI:
[
{
"stateMutability": "payable",
"type": "fallback"
},
{
"inputs": [
{
"internalType": "string",
"name": "account_name",
"type": "string"
}
],
"name": "accountUpdate",
"outputs": [
{
"internalType": "bytes32",
"name": "hash",
"type": "bytes32"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "url",
"type": "string"
},
{
"internalType": "uint256",
"name": "upgrade_fee",
"type": "uint256"
}
],
"name": "createWitness",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "frozen_balance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "frozen_duration",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "resource",
"type": "uint256"
},
{
"internalType": "address",
"name": "receiver_address",
"type": "address"
},
{
"internalType": "uint256[]",
"name": "stages",
"type": "uint256[]"
},
{
"internalType": "uint256[]",
"name": "frozen_balances",
"type": "uint256[]"
}
],
"name": "freezeBalance",
"outputs": [
{
"internalType": "bytes32",
"name": "hash",
"type": "bytes32"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "frozen_balance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "frozen_duration",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "resource",
"type": "uint256"
},
{
"internalType": "address",
"name": "receiver_address",
"type": "address"
},
{
"internalType": "uint256[]",
"name": "stages",
"type": "uint256[]"
},
{
"internalType": "uint256[]",
"name": "frozen_balances",
"type": "uint256[]"
},
{
"internalType": "bool[]",
"name": "refreezes",
"type": "bool[]"
}
],
"name": "freezeBalance",
"outputs": [
{
"internalType": "bytes32",
"name": "hash",
"type": "bytes32"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "frozen_balance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "frozen_duration",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "resource",
"type": "uint256"
},
{
"internalType": "address",
"name": "receiver_address",
"type": "address"
}
],
"name": "freezeBalance",
"outputs": [
{
"internalType": "bytes32",
"name": "hash",
"type": "bytes32"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner_address",
"type": "address"
}
],
"name": "getBrokerage",
"outputs": [
{
"internalType": "uint256",
"name": "brokerage",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "getNextMaintenanceTime",
"outputs": [
{
"internalType": "uint256",
"name": "num",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner_address",
"type": "address"
}
],
"name": "getReward",
"outputs": [
{
"internalType": "uint256",
"name": "reward",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "spreadReward",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "proposal_id",
"type": "uint256"
},
{
"internalType": "bool",
"name": "is_add_approval",
"type": "bool"
}
],
"name": "proposalApprove",
"outputs": [
{
"internalType": "bytes32",
"name": "hash",
"type": "bytes32"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "proposal_id",
"type": "uint256"
},
{
"internalType": "string",
"name": "proposal_value",
"type": "string"
}
],
"name": "proposalCreate",
"outputs": [
{
"internalType": "bytes32",
"name": "hash",
"type": "bytes32"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "proposal_id",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "proposal_value",
"type": "uint256"
}
],
"name": "proposalCreateUint",
"outputs": [
{
"internalType": "bytes32",
"name": "hash",
"type": "bytes32"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "proposal_id",
"type": "uint256"
}
],
"name": "proposalDelete",
"outputs": [
{
"internalType": "bytes32",
"name": "hash",
"type": "bytes32"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "resource",
"type": "uint256"
},
{
"internalType": "address",
"name": "receiver_address",
"type": "address"
}
],
"name": "unfreezeBalance",
"outputs": [
{
"internalType": "bytes32",
"name": "hash",
"type": "bytes32"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "resource",
"type": "uint256"
},
{
"internalType": "address",
"name": "receiver_address",
"type": "address"
},
{
"internalType": "uint256[]",
"name": "stages",
"type": "uint256[]"
}
],
"name": "unfreezeBalance",
"outputs": [
{
"internalType": "bytes32",
"name": "hash",
"type": "bytes32"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "brokerage",
"type": "uint256"
}
],
"name": "updateBrokerage",
"outputs": [
{
"internalType": "bytes32",
"name": "hash",
"type": "bytes32"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "update_url",
"type": "string"
}
],
"name": "updateWitness",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "vote_address",
"type": "address[]"
},
{
"internalType": "uint256[]",
"name": "vote_count",
"type": "uint256[]"
}
],
"name": "voteWitness",
"outputs": [
{
"internalType": "bytes32",
"name": "hash",
"type": "bytes32"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "withdraw_type",
"type": "uint256"
}
],
"name": "withdrawBalance",
"outputs": [
{
"internalType": "bytes32",
"name": "hash",
"type": "bytes32"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"stateMutability": "payable",
"type": "receive"
}
]
对应底层接口参照开发者中心API
事务类接口
冻结资源
-
普通冻结:freezeBalance(uint256 frozen_balance, uint256 frozen_duration, uint256 resource, address receiver_address)
参数:
frozen_balance:冻结金额,单位vdt
frozen_duration:冻结时间,
resource:光量子,熵,节点质押,社区节点投票
receiver_address: 接收地址,为自己冻结,则是自己的地址,为他人冻结,填他人地址,社区节点投票,填投票地址 -
多档冻结:freezeBalance(uint256 frozen_balance, uint256 frozen_duration, uint256 resource, address receiver_address, uint256[] memory stages, uint256[] memory frozen_balances, bool[] memory refreezes)
参数:
frozen_balance:冻结金额,单位vdt
frozen_duration:冻结时间
resource:光量子,熵
receiver_address: 接收地址,为自己冻结,则是自己的地址,为他人冻结,填他人地址
stages:冻结档位
frozen_balances:冻结档位对应的冻结量,单位vdt
refreezes: 档位对应是否复投,默认false,只允许单个档位复投,不允许批量复投
解冻资源
-
普通解冻:unfreezeBalance(uint256 resource, address receiver_address)
参数:
resource:光量子,熵,节点质押,社区节点投票
receiver_address: 解冻地址,为自己解冻,则是自己的地址,解冻为他人冻结的资源,填他人地址,社区节点解冻,填投票地址 -
多档解冻:unfreezeBalance(uint256 resource, address receiver_address, uint256[] memory stages)
参数:
resource:光量子,熵,节点质押,社区节点投票
receiver_address: 解冻地址,为自己解冻,则是自己的地址,解冻为他人冻结的资源,填他人地址,社区节点解除投票,填投票地址
stages:解冻档位
投票
- voteWitness(address[] memory vote_address, uint256[] memory vote_count)
参数:
vote_address:投票地址数组
vote_count: 投票数量数组,与投票地址一一对应
提取奖励
- withdrawBalance(uint256 withdraw_type)
参数:
withdraw_type:提取收益类型,0 - 全部提取,1 - 提取社区节点投票奖励
节点申请
- createWitness(string memory url, uint256 upgrade_fee)
参数:
url:申请节点需要配置的url
upgrade_fee: 升级成为节点需要消耗的vs数量
节点修改
- updateWitness(string memory update_url)
参数:
update_url:修改节点的url
节点佣金比例修改
- updateBrokerage(uint256 brokerage)
参数:
brokerage:设置给节点的瓜分比例,如20,则节点瓜分20%,选民瓜分80%
发起提议
- 发起普通提议:proposalCreateUint(uint256 proposal_id, uint256 proposal_value)
- 发起字符串提议:proposalCreate(uint256 proposal_id, string memory proposal_value)
参数:
proposal_id:对应提议的id
proposal_value:对应提议要修改的值
提议审核
- proposalApprove(uint256 proposal_id, bool is_add_approval)
参数:
proposal_id:对应提议的id
is_add_approval:审核的结果,true - 同意,false - 不同意
提议删除
- proposalDelete(uint256 proposal_id)
参数:
proposal_id:对应提议的id
修改账户名
- accountUpdate(string memory account_name)
参数:
account_name:账户名
查询类接口
查询奖励
- getReward(address owner_address) public returns(uint256 reward, uint256 spreadReward)
参数:
owner_address:指定地址
返回值:
reward:总的奖励,包含社区节点投票奖励
spreadReward:社区节点投票奖励
查询节点佣金比例
- getBrokerage(address owner_address) public returns(uint256 brokerage)
参数:
owner_address:指定节点的地址
返回值:
brokerage:节点的瓜分比例
查询下个维护周期的时间
- getNextMaintenanceTime() public returns (uint256 num)
返回值:
num:下个维护周期的时间戳,精确到毫秒
Updated about 2 years ago