Parameters
tx
string
Loading...
pub_key
object
Loading...
type
string
Loading...
key
string
Loading...
signature
string
Loading...
sender_address
string
Loading...
Returns
tx_hash
string
Loading...
height
string
Loading...
index
integer
Loading...
codespace
string
Loading...
code
integer
Loading...
data
string
Loading...
raw_log
string
Loading...
timestamp
string
Loading...
Request
1package main23import (4"context"5"crypto/tls"6"fmt"7"log"8"time"910"google.golang.org/grpc"11"google.golang.org/grpc/credentials"12"google.golang.org/grpc/metadata"13"google.golang.org/protobuf/encoding/protojson"1415pb "injective-indexer-grpc/pb/exchange"16)1718const grpcEndpoint = "YOUR_ENDPOINT_NAME.injective-mainnet.quiknode.pro:443"19const authToken = "YOUR_TOKEN"2021func main() {22creds := credentials.NewTLS(&tls.Config{MinVersion: tls.VersionTLS12})23conn, err := grpc.Dial(grpcEndpoint, grpc.WithTransportCredentials(creds))24if err != nil {25log.Fatal(err)26}27defer conn.Close()2829ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)30defer cancel()31ctx = metadata.AppendToOutgoingContext(ctx, "x-token", authToken)3233client := pb.NewInjectiveExchangeRPCClient(conn)34// WARNING: This method can change Mainnet state. The sample values are intentionally invalid.35request := &pb.BroadcastCosmosTxRequest{}36requestJSON := `{"tx":"AQ==","pub_key":{"type":"/injective.crypto.v1beta1.ethsecp256k1.PubKey","key":"020000000000000000000000000000000000000000000000000000000000000000"},"signature":"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","sender_address":"inj13rqjnfdlwqqkgfszzmdd7fjl8qwguf0n95jcpp"}`37if err := protojson.Unmarshal([]byte(requestJSON), request); err != nil {38log.Fatal(err)39}4041response, err := client.BroadcastCosmosTx(ctx, request)42if err != nil {43log.Fatal(err)44}4546data, err := protojson.MarshalOptions{UseProtoNames: true, Indent: " "}.Marshal(response)47if err != nil {48log.Fatal(err)49}50data = append(data, '\n')51fmt.Print(string(data))52}53
1package main23import (4"context"5"crypto/tls"6"fmt"7"log"8"time"910"google.golang.org/grpc"11"google.golang.org/grpc/credentials"12"google.golang.org/grpc/metadata"13"google.golang.org/protobuf/encoding/protojson"1415pb "injective-indexer-grpc/pb/exchange"16)1718const grpcEndpoint = "YOUR_ENDPOINT_NAME.injective-mainnet.quiknode.pro:443"19const authToken = "YOUR_TOKEN"2021func main() {22creds := credentials.NewTLS(&tls.Config{MinVersion: tls.VersionTLS12})23conn, err := grpc.Dial(grpcEndpoint, grpc.WithTransportCredentials(creds))24if err != nil {25log.Fatal(err)26}27defer conn.Close()2829ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)30defer cancel()31ctx = metadata.AppendToOutgoingContext(ctx, "x-token", authToken)3233client := pb.NewInjectiveExchangeRPCClient(conn)34// WARNING: This method can change Mainnet state. The sample values are intentionally invalid.35request := &pb.BroadcastCosmosTxRequest{}36requestJSON := `{"tx":"AQ==","pub_key":{"type":"/injective.crypto.v1beta1.ethsecp256k1.PubKey","key":"020000000000000000000000000000000000000000000000000000000000000000"},"signature":"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","sender_address":"inj13rqjnfdlwqqkgfszzmdd7fjl8qwguf0n95jcpp"}`37if err := protojson.Unmarshal([]byte(requestJSON), request); err != nil {38log.Fatal(err)39}4041response, err := client.BroadcastCosmosTx(ctx, request)42if err != nil {43log.Fatal(err)44}4546data, err := protojson.MarshalOptions{UseProtoNames: true, Indent: " "}.Marshal(response)47if err != nil {48log.Fatal(err)49}50data = append(data, '\n')51fmt.Print(string(data))52}53
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)2829// WARNING: This method can change Mainnet state. The sample values are intentionally invalid.30const request = {31tx: 'AQ==',32pub_key: {33type: '/injective.crypto.v1beta1.ethsecp256k1.PubKey',34key: '020000000000000000000000000000000000000000000000000000000000000000',35},36signature:37'00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',38sender_address: 'inj13rqjnfdlwqqkgfszzmdd7fjl8qwguf0n95jcpp',39}4041client.BroadcastCosmosTx(42request,43metadata,44{ deadline: Date.now() + 20000 },45(error, response) => {46if (error) {47console.error(error)48process.exitCode = 149return50}5152console.log(JSON.stringify(response, null, 2))53client.close()54}55)56
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)2829// WARNING: This method can change Mainnet state. The sample values are intentionally invalid.30const request = {31tx: 'AQ==',32pub_key: {33type: '/injective.crypto.v1beta1.ethsecp256k1.PubKey',34key: '020000000000000000000000000000000000000000000000000000000000000000',35},36signature:37'00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',38sender_address: 'inj13rqjnfdlwqqkgfszzmdd7fjl8qwguf0n95jcpp',39}4041client.BroadcastCosmosTx(42request,43metadata,44{ deadline: Date.now() + 20000 },45(error, response) => {46if (error) {47console.error(error)48process.exitCode = 149return50}5152console.log(JSON.stringify(response, null, 2))53client.close()54}55)56
1import json2import grpc3from google.protobuf.json_format import MessageToJson, ParseDict4from exchange import injective_exchange_rpc_pb25from exchange import injective_exchange_rpc_pb2_grpc67GRPC_ENDPOINT = "YOUR_ENDPOINT_NAME.injective-mainnet.quiknode.pro:443"8AUTH_TOKEN = "YOUR_TOKEN"910channel = grpc.secure_channel(GRPC_ENDPOINT, grpc.ssl_channel_credentials())11client = injective_exchange_rpc_pb2_grpc.InjectiveExchangeRPCStub(channel)12metadata = (("x-token", AUTH_TOKEN),)1314# WARNING: This method can change Mainnet state. The sample values are intentionally invalid.15request_data = {16"tx": "AQ==",17"pub_key": {18"type": "/injective.crypto.v1beta1.ethsecp256k1.PubKey",19"key": "020000000000000000000000000000000000000000000000000000000000000000"20},21"signature": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",22"sender_address": "inj13rqjnfdlwqqkgfszzmdd7fjl8qwguf0n95jcpp"23}24request = ParseDict(request_data, injective_exchange_rpc_pb2.BroadcastCosmosTxRequest())2526try:27response = client.BroadcastCosmosTx(request, metadata=metadata, timeout=20)28print(MessageToJson(response, preserving_proto_field_name=True, indent=2))29except grpc.RpcError as error:30print(f"gRPC error {error.code().name}: {error.details()}")31raise32finally:33channel.close()34
1import json2import grpc3from google.protobuf.json_format import MessageToJson, ParseDict4from exchange import injective_exchange_rpc_pb25from exchange import injective_exchange_rpc_pb2_grpc67GRPC_ENDPOINT = "YOUR_ENDPOINT_NAME.injective-mainnet.quiknode.pro:443"8AUTH_TOKEN = "YOUR_TOKEN"910channel = grpc.secure_channel(GRPC_ENDPOINT, grpc.ssl_channel_credentials())11client = injective_exchange_rpc_pb2_grpc.InjectiveExchangeRPCStub(channel)12metadata = (("x-token", AUTH_TOKEN),)1314# WARNING: This method can change Mainnet state. The sample values are intentionally invalid.15request_data = {16"tx": "AQ==",17"pub_key": {18"type": "/injective.crypto.v1beta1.ethsecp256k1.PubKey",19"key": "020000000000000000000000000000000000000000000000000000000000000000"20},21"signature": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",22"sender_address": "inj13rqjnfdlwqqkgfszzmdd7fjl8qwguf0n95jcpp"23}24request = ParseDict(request_data, injective_exchange_rpc_pb2.BroadcastCosmosTxRequest())2526try:27response = client.BroadcastCosmosTx(request, metadata=metadata, timeout=20)28print(MessageToJson(response, preserving_proto_field_name=True, indent=2))29except grpc.RpcError as error:30print(f"gRPC error {error.code().name}: {error.details()}")31raise32finally:33channel.close()34
Don't have an account yet?
Create your Quicknode endpoint in seconds and start building
Get started for free