darwinia-network / collaboration

Collaboration Initiatives
MIT License
7 stars 31 forks source link

RFP: A dev tool idea to support send runtime calls using wallets like metamask by adopting dispatch precompile #55

Open hackfisher opened 1 year ago

hackfisher commented 1 year ago

This can be easily constructed by the runtime calls component and dispatch js SDK

hackfisher commented 1 year ago

There is existing solution(thanks to @hujw77 ) using remix with the following contract's support:

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

contract Dispatch {
    fallback (bytes calldata _input) external payable returns (bytes memory _output)   {} 
}
[
    {
        "stateMutability": "payable",
        "type": "fallback"
    }
]

Compile this contract using remix first, then connect to you account using Inject Provider, copy dispatch precompile address and the encoded runtime call data from polkadot js:

Refer following interfaces:

https://docs.darwinia.network/builtin-precompiles-38faea0d12a648e9a061cf013e1cfdd6

image image
wuminzhe commented 2 months ago

https://jsfiddle.net/wuminzhe/5qx0pcej/1/

In vscode, there will be auto-completions.