1 配置metamask钱包网络环境
https://metamask.zendesk.com/hc/en-us/articles/360043227612-How-to-add-a-custom-network-RPC 《How to add a custom network RPC》
Network Name:Deeper
New RPC URL: https://mainnet.deeper.network/rpc
Chain ID:518
Currency Symbol:DPR
创建合约文件及部署流程见 https://remix-ide.readthedocs.io/en/latest/create_deploy.html
进入 https://remix.ethereum.org/ ,创建DepTaskBridge.sol
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
interface IDEP{
function nNodespecifiedAddressTask(
string calldata url,
string calldata options,
uint64 maxRunNum,
address[] memory receivers,
uint64 maintainBlocks
) external;
function blockUintPrice() external returns(uint64);
function proofUnit() external returns(uint256);
}
contract DepTaskBridge {
struct Task{
string url;
string options;
}
address public owner;
IDEP public dep;
Task public currentWork;
event NewTaskChange(string url, uint256 time);
modifier onlyOwner{
require(msg.sender == owner);
_;
}
constructor(address _dep) {
owner = msg.sender;
dep = IDEP(_dep);
}
function setDEP(IDEP _dep) external onlyOwner {
dep = _dep;
}
function setTask(string calldata workURL, string calldata options) external onlyOwner{
currentWork.url = workURL;
currentWork.options = options;
emit NewTaskChange(workURL, block.timestamp);
}
function payForTask(address[] memory user_address, uint64 maintainBlocks) external{
dep.nNodespecifiedAddressTask(currentWork.url, currentWork.options, 1, user_address, maintainBlocks);
}
}
3 编译合约
选择编译器版本(比如v0.8.12+commit.f00d7308),然后点击 “Compile DepTaskBridge.sol”
4 发布合约
选择ENVIRONMENT为 “injected Provider - Metamask”, 选择有余额的ACCOUNT,
填入官方DEP合约地址 0xC39acC1B3FA595BBaF916A5D6aD222afc91EB079,然后点击Deploy
5 设置docker镜像url, options运行参数,点击 “transact”
Example:
workURL:xbgxwh/battle_city:1.0.1
options:node index.js
交易确认后,可以点开,查看详情
6 等待用户调用
(1 )开发者可以在contract DepTaskBridge 内,定制自己的数据结构及业务逻辑
(2)后期开发者可以提交这个合约应用,应用在deeper设备的depDappStore列表展示,用户可以一键点击调用
参考
https://evm.deeper.network/address/0xE108c1F5Da817Bb2908a48BDE47B08B2f2731B29/contracts#address-tabs
https://remix-ide.readthedocs.io/en/latest/create_deploy.html