TriggerConstantContract - Tron
Example code for the TriggerConstantContract gRPC method. Complete guide on how to use TriggerConstantContract gRPC method in GetBlock Web3 documentation.
Was this helpful?
Was this helpful?
grpcurl -H 'x-api-key: <ACCESS-TOKEN>' \
-d '{"owner_address": "41f0cc5a2a84cd0f68ed1667070934542d673acbd8", "contract_address": "41a614f803b6fd780986a42c78ec9c7f77e6ded13c", "data": "70a08231000000000000000000000000f0cc5a2a84cd0f68ed1667070934542d673acbd8"}' \
go.getblock.io:443 protocol.Wallet/TriggerConstantContractimport grpc
# Stubs generated from java-tron's api.proto with grpcio-tools
from api import api_pb2_grpc
from core import Contract_pb2, Tron_pb2
creds = grpc.ssl_channel_credentials()
channel = grpc.secure_channel('go.getblock.io:443', creds)
metadata = [('x-api-key', '<ACCESS-TOKEN>')]
stub = api_pb2_grpc.WalletStub(channel)
response = stub.TriggerConstantContract(Contract_pb2.TriggerSmartContract(
owner_address=bytes.fromhex('41f0cc5a2a84cd0f68ed1667070934542d673acbd8'),
contract_address=bytes.fromhex('41a614f803b6fd780986a42c78ec9c7f77e6ded13c'),
data=bytes.fromhex('70a08231...')), metadata=metadata)
print(response)conn, _ := grpc.Dial(
"go.getblock.io:443",
grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),
)
defer conn.Close()
client := api.NewWalletClient(conn)
ctx := metadata.AppendToOutgoingContext(
context.Background(), "x-api-key", "<ACCESS-TOKEN>")
resp, _ := client.TriggerConstantContract(ctx, &core.TriggerSmartContract{OwnerAddress: owner, ContractAddress: contract, Data: callData})
fmt.Println(resp)