You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pb3-gen-sol is a proto3 to solidity library generator that supports proto3 native types and uses field option for solidity native types. Both the message and generated code are more efficient than other solutions. It also includes a library to decode protobuf wireformat. Currently it generates decoders, with encoder support planned.
3
+
4
+
pb3-gen-sol is a proto3 to solidity library generator that supports
5
+
proto3 native types and uses field option for solidity native types.
6
+
Both the message and generated code are more efficient than other
7
+
solutions. It also includes a library to decode protobuf wireformat.
8
+
Currently it generates decoders, with encoder support planned.
5
9
6
10
## Usage
7
11
### .proto files
8
12
Example:
9
13
```protobuf
10
14
syntax = "proto3";
11
-
// package name is used for both generated .sol file name and library name
15
+
// package name is used for both generated .sol file name and library
16
+
name
12
17
package mytest;
13
18
14
19
import "google/protobuf/descriptor.proto";
15
20
extend google.protobuf.FieldOptions {
16
-
string soltype = 54321; // must > 1001 and not conflict with other extensions
21
+
string soltype = 54321; // must > 1001 and not conflict with other
22
+
extensions
17
23
}
18
24
19
25
message MyMsg {
20
26
bytes addr = 1 [ (soltype) = "address" ];
21
27
uint32 num = 2 [ (soltype) = "uint8" ];
22
-
bool has_moon = 3; // for matching native types, no need for soltype option
28
+
bool has_moon = 3; // for matching native types, no need for
29
+
soltype option
23
30
}
24
31
```
25
32
Check .proto files under test folder for more examples.
@@ -33,19 +40,19 @@ $ export PATH=$PWD:$PATH
33
40
$ protoc --sol_out=. [list of proto files]
34
41
```
35
42
36
-
proto files can have different package names, and generated .sol file name is proto package name.
43
+
proto files can have different package names, and generated .sol file
44
+
name is proto package name.
37
45
38
46
## Params
39
-
-`msg`: only generate solidity struct and decode functions for msg name. Multiple can be specified.
40
-
-`importpb`: default false, if set to true, generated .sol file will import pb.sol instead of embed library pb in the file
47
+
-`msg`: only generate solidity struct and decode functions for msg
48
+
name. Multiple can be specified.
49
+
-`importpb`: default false, if set to true, generated .sol file will
50
+
import pb.sol instead of embed library pb in the file
0 commit comments