-
Notifications
You must be signed in to change notification settings - Fork 196
03Transactions
Pre-requisite reading: Cosmos SDK Transactions
State changes on Injective can be done through transactions. Users create transactions, sign them and broadcast them to Injective.
When broadcasted and only after every validation is successfully passed (these validations include signature validation, parameters validations, etc) the transaction is included within a block which is approved by the network through a consensus process.
Messages are the instructions included in transactions to specify the state change the user want to do. Every transaction has to have at least one message. Messages are module-specific objects that trigger state transitions within the scope of the module they belong to. We can pack multiple messages within the same transaction.
There is an abstraction class (MsgBase) that we export from the @injectivelabs/sdk-ts
and every message extends the MsgBase
interface, which has couple of mapping functionalities:
-
toData
-> Converts the Message to a simple Object representation, -
toProto
-> Returns a proto representation of the Message, -
toDirectSign
-> Converts the Message to a proto representation, -
toAmino
-> Converts the Message to a amino representation + type, -
toWeb3
-> alternative fortoAmino
, with the difference of the Message path type, -
toEip712Types
-> Generates the EIP712 types for the Message, -
toEip712
-> Generates the Message EIP712 value -
toJSON
-> Converts the message to a JSON representation,
Besides Message(s), every transaction has context. These details include fees
, accountDetails
, memo
, signatures
, etc.
Every transaction we want to broadcast to Injective has the same flow. The flow consists of three steps: preparing, signing and broadcasting the transaction.
Topic | Description |
---|---|
Using the Ethereum approach | Prepare/Sign EIP712 typed data then broadcast |
Using the Cosmos approach | Prepare/Sign/Broadcast Cosmos transactions |
Using a Private Key | Prepare/Sign/Broadcast Cosmos transaction with private key |
Web3Gateway Microservice | A microservice for supporting fee Delegation |
Msg Broadcaster | Abstraction for broadcasting messages |
The messages that are available (and examples) can be found in Core Modules section of the Wiki.
Powering the future of decentralized finance.