Skip to content

dantenetwork/message-ink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 

Repository files navigation

message_ink

web3 foundation_grants_badge_white

This is the message defination lib for the protocol stack in ink!.

Usage

  • Put Payload = { git = "https://github.com/dantenetwork/message_ink", branch = "main" } in your Cargo.toml of your contract project. Or clone it from "https://github.com/dantenetwork/message_ink" and substitute with your related local path.

Main API

The interaction message between ink! smart contract and others(deployed on other chains) are expressed as MessagePayload, which is composited with a vector of MessageItem. The core part of MessageItem is MsgDetail, which defines almost every useful types.

A convenient way to Build a MsgDetail is as follows:

  • The trait InMsgType is defined to create an instance of MsgDetail from a normal type and decode out a normal type from MsgDetail.
pub trait InMsgType {
    type MyType;
    fn get_value(type_value: & MsgDetail) -> Option<Self::MyType>;
    fn create_message(msg_detail: Self::MyType) -> MsgDetail;
}
  • As enum variants are not types, we provide an implementation of every type defined in MsgDetail separately.

In addition, with the help of InMsgType for MsgDetail, MessageItem can be directly decoded into a normal type with x.in_to(), in which x is an instance of MessageItem.

That's the main interface of the message protocol for ink! smart contracts, that is very easy to use.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages