github.com/s7techlab/cckit@v0.10.5/examples/erc20_service/erc20.proto (about) 1 syntax = "proto3"; 2 3 option go_package = "github.com/s7techlab/cckit/examples/erc20_service"; 4 package examples.erc20_service; 5 6 import "google/api/annotations.proto"; 7 import "google/protobuf/empty.proto"; 8 9 // ERC-20 10 service ERC20 { 11 // Returns the name of the token. 12 rpc Name(google.protobuf.Empty) returns (NameResponse) { 13 option (google.api.http) = { 14 get: "/name" 15 }; 16 } 17 18 // Returns the symbol of the token, usually a shorter version of the name. 19 rpc Symbol(google.protobuf.Empty) returns (SymbolResponse) { 20 option (google.api.http) = { 21 get: "/symbol" 22 }; 23 } 24 25 // Returns the number of decimals used to get its user representation. 26 // For example, if decimals equals 2, a balance of 505 tokens should be displayed to a user as 5,05 (505 / 10 ** 2). 27 rpc Decimals (google.protobuf.Empty) returns (DecimalsResponse) { 28 option (google.api.http) = { 29 get: "/decimals" 30 }; 31 } 32 33 // Returns the amount of tokens in existence. 34 rpc TotalSupply (google.protobuf.Empty) returns (TotalSupplyResponse) { 35 option (google.api.http) = { 36 get: "/total-supply" 37 }; 38 } 39 40 // Returns the amount of tokens owned by account. 41 rpc BalanceOf (BalanceOfRequest) returns (BalanceOfResponse) { 42 option (google.api.http) = { 43 get: "/balance/{address}" 44 }; 45 } 46 47 // Moves amount tokens from the caller’s account to recipient. 48 // Returns a boolean value indicating whether the operation succeeded. 49 rpc Transfer (TransferRequest) returns (TransferResponse) { 50 option (google.api.http) = { 51 post: "/transfer" 52 }; 53 } 54 55 // Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through transfersender. 56 // This is zero by default. 57 rpc Allowance (AllowanceRequest) returns (AllowanceResponse) { 58 option (google.api.http) = { 59 get: "/allowance/{sender_address}/{recipient_address}" 60 }; 61 } 62 63 // Sets amount as the allowance of spender over the caller’s tokens. 64 // Emits an ApprovalEvent 65 rpc Approve (ApproveRequest) returns (ApproveResponse) { 66 option (google.api.http) = { 67 post: "/approve" 68 }; 69 } 70 71 // Moves amount tokens from sender to recipient using the allowance mechanism. 72 // Amount is then deducted from the caller’s allowance. 73 // Emits TransferEvent 74 rpc TransferFrom (TransferFromRequest) returns (TransferResponse) { 75 option (google.api.http) = { 76 post: "/transfer-from" 77 }; 78 } 79 } 80 81 message NameResponse { 82 string name = 1; 83 } 84 85 message SymbolResponse { 86 string symbol = 1; 87 } 88 89 message DecimalsResponse { 90 uint32 decimals = 1; 91 } 92 93 message TotalSupplyResponse { 94 uint64 total_supply = 1; 95 } 96 97 message BalanceOfRequest { 98 string address = 1; 99 } 100 101 message BalanceOfResponse { 102 string address = 1; 103 uint64 balance = 2; 104 } 105 106 message TransferRequest { 107 string recipient_address = 1; 108 uint64 amount = 2; 109 } 110 111 message TransferResponse { 112 string sender_address = 1; 113 string recipient_address = 2; 114 uint64 amount = 3; 115 } 116 117 message AllowanceRequest { 118 string sender_address = 1; 119 string recipient_address = 2; 120 } 121 122 message AllowanceResponse { 123 string sender_address = 1; 124 string recipient_address = 2; 125 uint64 amount = 3; 126 } 127 128 message ApproveRequest { 129 string sender_address = 1; 130 string recipient_address = 2; 131 uint64 amount = 3; 132 } 133 134 message ApproveResponse { 135 string sender_address = 1; 136 string recipient_address = 2; 137 uint64 amount = 3; 138 } 139 140 message TransferFromRequest { 141 string sender_address = 1; 142 string recipient_address = 2; 143 uint64 amount = 3; 144 } 145 146 // Events 147 148 message TransferEvent { 149 string sender_address = 1; 150 string recipient_address = 2; 151 uint64 amount = 3; 152 } 153 154 message ApprovalEvent { 155 string sender_address = 1; 156 string recipient_address = 2; 157 uint64 amount = 3; 158 }