Parameters
The numeric Web3 chain ID used in the EIP-712 signing domain. Injective Mainnet accepts 1 (Ethereum Mainnet) or 1776 (Injective EVM Mainnet).
The Ethereum-format address of the transaction signer.
The current on-chain sequence number, or nonce, of the transaction signer.
The on-chain account number of the transaction signer.
The optional text memo to include in the transaction.
The block height after which the transaction is no longer valid.
The gas price, gas limit, and delegation preference for the transaction.
The coin amounts that define the transaction gas price.
The denomination of the coin used to pay the gas fee.
The decimal coin amount used for the transaction gas price.
The maximum amount of gas the transaction may consume.
Whether the transaction must use delegated fee payment.
The Cosmos message JSON documents to include in the transaction, each UTF-8 encoded and represented as base64 in JSON requests.
The EIP-712 wrapper version to use. Accepted values are v1 and v2, case-insensitively.
Returns
The EIP-712 typed-data payload to sign with eth_signTypedData_v4.
1package main23import (4"context"5"crypto/tls"6"encoding/base64"7"fmt"8"log"9"time"1011"google.golang.org/grpc"12"google.golang.org/grpc/credentials"13"google.golang.org/grpc/metadata"14"google.golang.org/protobuf/encoding/protojson"1516pb "injective-indexer-grpc/pb/exchange"17)1819const grpcEndpoint = "YOUR_ENDPOINT_NAME.injective-mainnet.quiknode.pro:443"20const authToken = "YOUR_TOKEN"2122func main() {23creds := credentials.NewTLS(&tls.Config{MinVersion: tls.VersionTLS12})24conn, err := grpc.Dial(grpcEndpoint, grpc.WithTransportCredentials(creds))25if err != nil {26log.Fatal(err)27}28defer conn.Close()2930ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)31defer cancel()32ctx = metadata.AppendToOutgoingContext(ctx, "x-token", authToken)3334client := pb.NewInjectiveExchangeRPCClient(conn)35request := &pb.PrepareEip712Request{}36messageJSON := `{"@type":"/cosmos.bank.v1beta1.MsgSend","from_address":"inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z","to_address":"inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z","amount":[{"denom":"inj","amount":"1"}]}`37message := base64.StdEncoding.EncodeToString([]byte(messageJSON))38requestJSON := fmt.Sprintf(`{"chain_id":"1","signer_address":"0xf22dccace9d0610334f32637100cad2934528f81","sequence":"1","account_number":"1","fee":{"price":[{"denom":"inj","amount":"500000000000000"}]},"msgs":[%q],"eip712_wrapper":"v2"}`, message)39if err := protojson.Unmarshal([]byte(requestJSON), request); err != nil {40log.Fatal(err)41}4243response, err := client.PrepareEip712(ctx, request)44if err != nil {45log.Fatal(err)46}4748data, err := protojson.MarshalOptions{UseProtoNames: true, Indent: " "}.Marshal(response)49if err != nil {50log.Fatal(err)51}52data = append(data, '\n')53fmt.Print(string(data))54}55
1package main23import (4"context"5"crypto/tls"6"encoding/base64"7"fmt"8"log"9"time"1011"google.golang.org/grpc"12"google.golang.org/grpc/credentials"13"google.golang.org/grpc/metadata"14"google.golang.org/protobuf/encoding/protojson"1516pb "injective-indexer-grpc/pb/exchange"17)1819const grpcEndpoint = "YOUR_ENDPOINT_NAME.injective-mainnet.quiknode.pro:443"20const authToken = "YOUR_TOKEN"2122func main() {23creds := credentials.NewTLS(&tls.Config{MinVersion: tls.VersionTLS12})24conn, err := grpc.Dial(grpcEndpoint, grpc.WithTransportCredentials(creds))25if err != nil {26log.Fatal(err)27}28defer conn.Close()2930ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)31defer cancel()32ctx = metadata.AppendToOutgoingContext(ctx, "x-token", authToken)3334client := pb.NewInjectiveExchangeRPCClient(conn)35request := &pb.PrepareEip712Request{}36messageJSON := `{"@type":"/cosmos.bank.v1beta1.MsgSend","from_address":"inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z","to_address":"inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z","amount":[{"denom":"inj","amount":"1"}]}`37message := base64.StdEncoding.EncodeToString([]byte(messageJSON))38requestJSON := fmt.Sprintf(`{"chain_id":"1","signer_address":"0xf22dccace9d0610334f32637100cad2934528f81","sequence":"1","account_number":"1","fee":{"price":[{"denom":"inj","amount":"500000000000000"}]},"msgs":[%q],"eip712_wrapper":"v2"}`, message)39if err := protojson.Unmarshal([]byte(requestJSON), request); err != nil {40log.Fatal(err)41}4243response, err := client.PrepareEip712(ctx, request)44if err != nil {45log.Fatal(err)46}4748data, err := protojson.MarshalOptions{UseProtoNames: true, Indent: " "}.Marshal(response)49if err != nil {50log.Fatal(err)51}52data = append(data, '\n')53fmt.Print(string(data))54}55
1const grpc = require('@grpc/grpc-js')2const protoLoader = require('@grpc/proto-loader')3const path = require('path')45const GRPC_ENDPOINT = 'YOUR_ENDPOINT_NAME.injective-mainnet.quiknode.pro:443'6const AUTH_TOKEN = 'YOUR_TOKEN'78const definition = protoLoader.loadSync(9path.join(__dirname, 'proto/exchange/injective_exchange_rpc.proto'),10{11keepCase: true,12longs: String,13enums: String,14bytes: String,15defaults: true,16oneofs: true,17}18)1920const proto = grpc.loadPackageDefinition(definition).injective_exchange_rpc21const client = new proto.InjectiveExchangeRPC(22GRPC_ENDPOINT,23grpc.credentials.createSsl()24)2526const metadata = new grpc.Metadata()27metadata.add('x-token', AUTH_TOKEN)2829const message = {30'@type': '/cosmos.bank.v1beta1.MsgSend',31from_address: 'inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z',32to_address: 'inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z',33amount: [{ denom: 'inj', amount: '1' }],34}3536const request = {37chain_id: '1',38signer_address: '0xf22dccace9d0610334f32637100cad2934528f81',39sequence: '1',40account_number: '1',41fee: {42price: [43{44denom: 'inj',45amount: '500000000000000',46},47],48},49msgs: [Buffer.from(JSON.stringify(message))],50eip712_wrapper: 'v2',51}5253client.PrepareEip712(54request,55metadata,56{ deadline: Date.now() + 20000 },57(error, response) => {58if (error) {59console.error(error)60process.exitCode = 161return62}6364console.log(JSON.stringify(response, null, 2))65client.close()66}67)68
1const grpc = require('@grpc/grpc-js')2const protoLoader = require('@grpc/proto-loader')3const path = require('path')45const GRPC_ENDPOINT = 'YOUR_ENDPOINT_NAME.injective-mainnet.quiknode.pro:443'6const AUTH_TOKEN = 'YOUR_TOKEN'78const definition = protoLoader.loadSync(9path.join(__dirname, 'proto/exchange/injective_exchange_rpc.proto'),10{11keepCase: true,12longs: String,13enums: String,14bytes: String,15defaults: true,16oneofs: true,17}18)1920const proto = grpc.loadPackageDefinition(definition).injective_exchange_rpc21const client = new proto.InjectiveExchangeRPC(22GRPC_ENDPOINT,23grpc.credentials.createSsl()24)2526const metadata = new grpc.Metadata()27metadata.add('x-token', AUTH_TOKEN)2829const message = {30'@type': '/cosmos.bank.v1beta1.MsgSend',31from_address: 'inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z',32to_address: 'inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z',33amount: [{ denom: 'inj', amount: '1' }],34}3536const request = {37chain_id: '1',38signer_address: '0xf22dccace9d0610334f32637100cad2934528f81',39sequence: '1',40account_number: '1',41fee: {42price: [43{44denom: 'inj',45amount: '500000000000000',46},47],48},49msgs: [Buffer.from(JSON.stringify(message))],50eip712_wrapper: 'v2',51}5253client.PrepareEip712(54request,55metadata,56{ deadline: Date.now() + 20000 },57(error, response) => {58if (error) {59console.error(error)60process.exitCode = 161return62}6364console.log(JSON.stringify(response, null, 2))65client.close()66}67)68
1import base642import json3import grpc4from google.protobuf.json_format import MessageToJson, ParseDict5from exchange import injective_exchange_rpc_pb26from exchange import injective_exchange_rpc_pb2_grpc78GRPC_ENDPOINT = "YOUR_ENDPOINT_NAME.injective-mainnet.quiknode.pro:443"9AUTH_TOKEN = "YOUR_TOKEN"1011channel = grpc.secure_channel(GRPC_ENDPOINT, grpc.ssl_channel_credentials())12client = injective_exchange_rpc_pb2_grpc.InjectiveExchangeRPCStub(channel)13metadata = (("x-token", AUTH_TOKEN),)1415message = {16"@type": "/cosmos.bank.v1beta1.MsgSend",17"from_address": "inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z",18"to_address": "inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z",19"amount": [{"denom": "inj", "amount": "1"}]20}21encoded_message = base64.b64encode(json.dumps(message, separators=(",", ":")).encode()).decode()2223request_data = {24"chain_id": "1",25"signer_address": "0xf22dccace9d0610334f32637100cad2934528f81",26"sequence": "1",27"account_number": "1",28"fee": {29"price": [30{31"denom": "inj",32"amount": "500000000000000"33}34]35},36"msgs": [37encoded_message38],39"eip712_wrapper": "v2"40}41request = ParseDict(request_data, injective_exchange_rpc_pb2.PrepareEip712Request())4243try:44response = client.PrepareEip712(request, metadata=metadata, timeout=20)45print(MessageToJson(response, preserving_proto_field_name=True, indent=2))46except grpc.RpcError as error:47print(f"gRPC error {error.code().name}: {error.details()}")48raise49finally:50channel.close()51
1import base642import json3import grpc4from google.protobuf.json_format import MessageToJson, ParseDict5from exchange import injective_exchange_rpc_pb26from exchange import injective_exchange_rpc_pb2_grpc78GRPC_ENDPOINT = "YOUR_ENDPOINT_NAME.injective-mainnet.quiknode.pro:443"9AUTH_TOKEN = "YOUR_TOKEN"1011channel = grpc.secure_channel(GRPC_ENDPOINT, grpc.ssl_channel_credentials())12client = injective_exchange_rpc_pb2_grpc.InjectiveExchangeRPCStub(channel)13metadata = (("x-token", AUTH_TOKEN),)1415message = {16"@type": "/cosmos.bank.v1beta1.MsgSend",17"from_address": "inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z",18"to_address": "inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z",19"amount": [{"denom": "inj", "amount": "1"}]20}21encoded_message = base64.b64encode(json.dumps(message, separators=(",", ":")).encode()).decode()2223request_data = {24"chain_id": "1",25"signer_address": "0xf22dccace9d0610334f32637100cad2934528f81",26"sequence": "1",27"account_number": "1",28"fee": {29"price": [30{31"denom": "inj",32"amount": "500000000000000"33}34]35},36"msgs": [37encoded_message38],39"eip712_wrapper": "v2"40}41request = ParseDict(request_data, injective_exchange_rpc_pb2.PrepareEip712Request())4243try:44response = client.PrepareEip712(request, metadata=metadata, timeout=20)45print(MessageToJson(response, preserving_proto_field_name=True, indent=2))46except grpc.RpcError as error:47print(f"gRPC error {error.code().name}: {error.details()}")48raise49finally:50channel.close()51