Creating Protobuf Schemas
Now that our manifest has been written, it is time to create your custom Protobuf definition, the one we'll use as an input/output in your manifest file.
Protocol Buffers are Google's language-neutral extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler. If you have not used Protobuf before, here are a couple of resources to get started:
We have defined a protobuf __ model as proto:eth.erc721.v1.Transfers which represents a list of ERC721 transfers.
Firstly, let's create the proto folder:
mkdir proto
cd proto
and in there, create our first protobuf definition file:
syntax = "proto3";
package eth.erc721.v1;
message Transfers {
repeated Transfer transfers = 1;
message Transfer {
bytes from = 1;
bytes to = 2;
uint64 token_id = 3;
bytes trx_hash = 4;
uint64 ordinal = 5;
It is recommended that you use a fully qualified path for your protobuf files, so there are fewer risks of conflict when people build on your Substreams Package.
Now that we have created our custom Protobuf definition file, we will generate the associated Rust code.
substreams protogen ./substreams.yaml --exclude-paths="sf/ethereum,sf/substreams,google"
You should now see your generated Rust code here src/pb/
Lastly, we will add a file in the src/pb directory to export the newly generated Rust code:
#[path = ""]
pub mod erc721;
Copy link