VerifySignature gRPC Method
参数
消息
对象
必填
正在加载...
签名
对象
必填
正在加载...
地址
字符串
正在加载...
jwks
数组
正在加载...
退货
isValid
布尔型
正在加载...
reason
字符串
正在加载...
请求
1grpcurl -import-path . \2-proto sui/rpc/v2/signature_verification_service.proto \3-H "x-token: abcde123456789" \4-d '{5"message": {6"name": "PersonalMessage",7"value": "BASE64_MESSAGE_BYTES"8},9"signature": {10"方案": "ED25519",11"signature": "BASE64_SIGNATURE",12"public_key": "BASE64_PUBLIC_KEY"13},14"address": "0xOPTIONAL_VERIFY_AGAINST_THIS_ADDRESS"15}' \16docs-demo.mainnet.quiknode.pro:9000 \17sui.rpc.v2.SignatureVerificationService/VerifySignature18
1grpcurl -import-path . \2-proto sui/rpc/v2/signature_verification_service.proto \3-H "x-token: abcde123456789" \4-d '{5"message": {6"name": "PersonalMessage",7"value": "BASE64_MESSAGE_BYTES"8},9"signature": {10"方案": "ED25519",11"signature": "BASE64_SIGNATURE",12"public_key": "BASE64_PUBLIC_KEY"13},14"address": "0xOPTIONAL_VERIFY_AGAINST_THIS_ADDRESS"15}' \16docs-demo.mainnet.quiknode.pro:9000 \17sui.rpc.v2.SignatureVerificationService/VerifySignature18
1包 main23import (4"上下文"5"crypto/tls"6"encoding/json"7"fmt"8“日志”9“时间”1011"google.golang.grpc"12"google.golang.grpc"13"google.golang.org/protobuf/encoding/protojson"14"google.golang.org/protobuf/types/known/fieldmaskpb"1516pb "sui" // 您生成的 .pb.go 文件路径17)1819// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token20// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678921// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}22// token will be : abcde1234567892324var (25token = "您的令牌编号"26endpoint = "您的QN端点:9000"27)2829// Auth structure for x-token30类型 auth 结构体 {31token 字符串32}3334func (a *auth) GetRequestMetadata(ctx 上下文.Context, uri ...字符串) (map[字符串]字符串, error) {35return map[string]string{"x-token": a.token}, nil36}37func (a *auth) RequireTransportSecurity() bool {38返回 true39}4041func main() {42creds := credentials.NewTLS(&tls.Config{})43opts := []grpc.DialOption{44grpc.WithTransportCredentials(creds),45grpc.WithPerRPCCredentials(&auth{令牌}),46}4748conn, err := grpc.Dial(endpoint, opts...)49如果 err != nil {50log.Fatalf("连接失败:%v", err)51}52推迟 conn.关闭()5354client := pb.NewSignatureVerificationServiceClient(conn)5556req := &pb.VerifySignatureRequest{57Signature: &pb.Signature{58Scheme: 0, // ED2551959Signature: []byte("YOUR_SIGNATURE_BYTES"), // Replace with actual signature60PublicKey: []byte("YOUR_PUBLIC_KEY_BYTES"), // Replace with actual public key61},62Message: []byte("YOUR_MESSAGE_BYTES"), // Replace with actual message63ReadMask: &fieldmaskpb.FieldMask{64Paths: []string{65"is_valid",66"error",67},68},69}7071ctx, 取消 := context.带超时(context.Background(), 10*时间.第二次)72推迟 取消()7374resp, err := client.VerifySignature(ctx, req)75如果 err != nil {76log.Fatalf("VerifySignature failed: %v", err)77}7879// Pretty print the response80marshaler := protojson.MarshalOptions{81UseProtoNames: true,82EmitUnpopulated: true,83缩进: " ",84}8586jsonBytes, err := marshaler.Marshal(resp)87如果 err != nil {88log.Fatalf(“序列化失败:%v”, err)89}9091var pretty map[字符串]接口{}92if err := json.Unmarshal(jsonBytes, &pretty); err != nil {93log.Fatalf(“无法解析 JSON:%v”, err)94}9596out, _ := json.MarshalIndent(pretty, "", " ")97fmt.Println(字符串(out))98}99
1包 main23import (4"上下文"5"crypto/tls"6"encoding/json"7"fmt"8“日志”9“时间”1011"google.golang.grpc"12"google.golang.grpc"13"google.golang.org/protobuf/encoding/protojson"14"google.golang.org/protobuf/types/known/fieldmaskpb"1516pb "sui" // 您生成的 .pb.go 文件路径17)1819// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token20// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678921// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}22// token will be : abcde1234567892324var (25token = "您的令牌编号"26endpoint = "您的QN端点:9000"27)2829// Auth structure for x-token30类型 auth 结构体 {31token 字符串32}3334func (a *auth) GetRequestMetadata(ctx 上下文.Context, uri ...字符串) (map[字符串]字符串, error) {35return map[string]string{"x-token": a.token}, nil36}37func (a *auth) RequireTransportSecurity() bool {38返回 true39}4041func main() {42creds := credentials.NewTLS(&tls.Config{})43opts := []grpc.DialOption{44grpc.WithTransportCredentials(creds),45grpc.WithPerRPCCredentials(&auth{令牌}),46}4748conn, err := grpc.Dial(endpoint, opts...)49如果 err != nil {50log.Fatalf("连接失败:%v", err)51}52推迟 conn.关闭()5354client := pb.NewSignatureVerificationServiceClient(conn)5556req := &pb.VerifySignatureRequest{57Signature: &pb.Signature{58Scheme: 0, // ED2551959Signature: []byte("YOUR_SIGNATURE_BYTES"), // Replace with actual signature60PublicKey: []byte("YOUR_PUBLIC_KEY_BYTES"), // Replace with actual public key61},62Message: []byte("YOUR_MESSAGE_BYTES"), // Replace with actual message63ReadMask: &fieldmaskpb.FieldMask{64Paths: []string{65"is_valid",66"error",67},68},69}7071ctx, 取消 := context.带超时(context.Background(), 10*时间.第二次)72推迟 取消()7374resp, err := client.VerifySignature(ctx, req)75如果 err != nil {76log.Fatalf("VerifySignature failed: %v", err)77}7879// Pretty print the response80marshaler := protojson.MarshalOptions{81UseProtoNames: true,82EmitUnpopulated: true,83缩进: " ",84}8586jsonBytes, err := marshaler.Marshal(resp)87如果 err != nil {88log.Fatalf(“序列化失败:%v”, err)89}9091var pretty map[字符串]接口{}92if err := json.Unmarshal(jsonBytes, &pretty); err != nil {93log.Fatalf(“无法解析 JSON:%v”, err)94}9596out, _ := json.MarshalIndent(pretty, "", " ")97fmt.Println(字符串(out))98}99
1import * 作为 grpc from grpc;2import * 作为 protoLoader from grpc;3import * 作为 路径 from '路径';45// Configuration6const PROTO_PATH = path.join(__dirname, 'protos/proto/sui/rpc/v2/signature_verification_service.proto');78// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token9// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678910// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}11// token will be : abcde1234567891213const endpoint = 'docs-demo.mainnet.quiknode.pro:9000';14const 令牌 = 'abcde123456789';1516// Load protobuf definitions17const 包定义 = protoLoader.loadSync(PROTO_PATH, {18keepCase: true,19多头: 字符串,20枚举: 字符串,21默认值: true,22oneofs: true,23includeDirs: [路径.join(__dirname, 'protos/proto')],24});2526const proto = grpc.loadPackageDefinition(packageDefinition) 作为 any;27const SignatureVerificationService = proto.sui.rpc.v2.SignatureVerificationService;2829// Create secure client30const client = new SignatureVerificationService(endpoint, grpc.credentials.createSsl());3132// Add token metadata33const 元数据 = new grpc.元数据();34元数据.添加('x-token', token);3536// Request payload37const 请求 = {38signature: {39scheme: 0, // ED2551940signature: Buffer.from('YOUR_SIGNATURE_BYTES', 'base64'), // Replace with actual signature41public_key: Buffer.from('YOUR_PUBLIC_KEY_BYTES', 'base64') // Replace with actual public key42},43message: Buffer.from('YOUR_MESSAGE_BYTES', 'base64'), // Replace with actual message44read_mask: {45paths: [46'is_valid',47'error',48],49},50};5152// Perform gRPC call53client.VerifySignature(request, metadata, (err: grpc.ServiceError | null, response: any) => {54如果 (err) {55console.error('gRPC Error:', {56代码: err.代码,57消息: err.消息,58详细信息: err.详情,59});60} else {61console.log('VerifySignature Response:');62控制台.日志(JSON.stringify(response, null, 2));63}64});65
1import * 作为 grpc from grpc;2import * 作为 protoLoader from grpc;3import * 作为 路径 from '路径';45// Configuration6const PROTO_PATH = path.join(__dirname, 'protos/proto/sui/rpc/v2/signature_verification_service.proto');78// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token9// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678910// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}11// token will be : abcde1234567891213const endpoint = 'docs-demo.mainnet.quiknode.pro:9000';14const 令牌 = 'abcde123456789';1516// Load protobuf definitions17const 包定义 = protoLoader.loadSync(PROTO_PATH, {18keepCase: true,19多头: 字符串,20枚举: 字符串,21默认值: true,22oneofs: true,23includeDirs: [路径.join(__dirname, 'protos/proto')],24});2526const proto = grpc.loadPackageDefinition(packageDefinition) 作为 any;27const SignatureVerificationService = proto.sui.rpc.v2.SignatureVerificationService;2829// Create secure client30const client = new SignatureVerificationService(endpoint, grpc.credentials.createSsl());3132// Add token metadata33const 元数据 = new grpc.元数据();34元数据.添加('x-token', token);3536// Request payload37const 请求 = {38signature: {39scheme: 0, // ED2551940signature: Buffer.from('YOUR_SIGNATURE_BYTES', 'base64'), // Replace with actual signature41public_key: Buffer.from('YOUR_PUBLIC_KEY_BYTES', 'base64') // Replace with actual public key42},43message: Buffer.from('YOUR_MESSAGE_BYTES', 'base64'), // Replace with actual message44read_mask: {45paths: [46'is_valid',47'error',48],49},50};5152// Perform gRPC call53client.VerifySignature(request, metadata, (err: grpc.ServiceError | null, response: any) => {54如果 (err) {55console.error('gRPC Error:', {56代码: err.代码,57消息: err.消息,58详细信息: err.详情,59});60} else {61console.log('VerifySignature Response:');62控制台.日志(JSON.stringify(response, null, 2));63}64});65
1import grpc2导入 json3来源 谷歌.protobuf.field_mask_pb2 导入 FieldMask4来源 谷歌.protobuf.json_format import MessageToDict5from sui.rpc.v2 import signature_verification_service_pb2, signature_verification_service_pb2_grpc678def verify_signature():910#Quicknode 由两个关键组成部分构成:endpoint 和相应的令牌11# 例如:QNEndpoint:mainnet12# endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}13# token will be : abcde1234567891415endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';16token = 'abcde123456789';1718频道 = grpc.secure_channel(endpoint, grpc.ssl_channel_credentials())19stub = signature_verification_service_pb2_grpc.SignatureVerificationServiceStub(channel)2021read_mask = 字段掩码(路径=[22"is_valid",23"error"24])2526request = signature_verification_service_pb2.VerifySignatureRequest(27signature=signature_verification_service_pb2.Signature(28scheme=0, # ED2551929signature=b"YOUR_SIGNATURE_BYTES", # Replace with actual signature30public_key=b"YOUR_PUBLIC_KEY_BYTES" # Replace with actual public key31),32message=b"YOUR_MESSAGE_BYTES", # Replace with actual message33read_mask=read_mask34)3536元数据 = [("x-token", token)]3738return stub.VerifySignature(request, metadata=metadata)394041def parse_response_to_json(response):42返回 json.dumps(43MessageToDict(response, 保留_proto_字段_名称=True),44缩进=245)464748def main():49试一试:50response = verify_signature()51打印(parse_response_to_json(response))52除了 grpc。RpcError 作为 e:53print(f"{e.code().name}: {e.details()}")545556如果 __name__ == "__main__":57主()58
1import grpc2导入 json3来源 谷歌.protobuf.field_mask_pb2 导入 FieldMask4来源 谷歌.protobuf.json_format import MessageToDict5from sui.rpc.v2 import signature_verification_service_pb2, signature_verification_service_pb2_grpc678def verify_signature():910#Quicknode 由两个关键组成部分构成:endpoint 和相应的令牌11# 例如:QNEndpoint:mainnet12# endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}13# token will be : abcde1234567891415endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';16token = 'abcde123456789';1718频道 = grpc.secure_channel(endpoint, grpc.ssl_channel_credentials())19stub = signature_verification_service_pb2_grpc.SignatureVerificationServiceStub(channel)2021read_mask = 字段掩码(路径=[22"is_valid",23"error"24])2526request = signature_verification_service_pb2.VerifySignatureRequest(27signature=signature_verification_service_pb2.Signature(28scheme=0, # ED2551929signature=b"YOUR_SIGNATURE_BYTES", # Replace with actual signature30public_key=b"YOUR_PUBLIC_KEY_BYTES" # Replace with actual public key31),32message=b"YOUR_MESSAGE_BYTES", # Replace with actual message33read_mask=read_mask34)3536元数据 = [("x-token", token)]3738return stub.VerifySignature(request, metadata=metadata)394041def parse_response_to_json(response):42返回 json.dumps(43MessageToDict(response, 保留_proto_字段_名称=True),44缩进=245)464748def main():49试一试:50response = verify_signature()51打印(parse_response_to_json(response))52除了 grpc。RpcError 作为 e:53print(f"{e.code().name}: {e.details()}")545556如果 __name__ == "__main__":57主()58