ink! Meta transaction contract implementations. Contracts are implemented based on the ERC2771 specifications. Corresponding solidity implementations can be found here.
Forwarder
contract - Forwarder contracts verify signers' signature and forward transaction requests to actual callee contracts.
MetaTxContext
crate - Callee contracts which want to make use of signers' information need to implements MetaTxContext
trait.
Registry
contract - An example contract implementing MetaTxContext
.
- Run local node e.g. swanky-node
- Install dependencies.
yarn
. - Test.
yarn test
.
Original forwarder contract implementation with no MetaTxContract can be found here. The Forwarder contract in this reposiroty is referencing to original implementation, and small modifications were added to it.
- Import
meta-tx-context
crate. - Use crate and implement
MetaTxContext
trait.
use meta_tx_context::*;
impl MetaTxContext for Contract {}
- Take Uint8 Vec
Vec<u8>
as the last argment of messages. For example,
pub fn register(&mut self, name: String, data: Vec<u8>) -> Result<(), Error> {}
This is needed to decode call inputs which cotains Signer's AccountId as the extra 32bytes attached by Forwarder contract.
- Use
self._caller(data)
instead ofself.env().caller()
.