Skip to content

Instantly share code, notes, and snippets.

@pietgeursen
Last active May 7, 2020 16:19
Show Gist options
  • Select an option

  • Save pietgeursen/7fed64678ae0389411c3872c48ddb508 to your computer and use it in GitHub Desktop.

Select an option

Save pietgeursen/7fed64678ae0389411c3872c48ddb508 to your computer and use it in GitHub Desktop.

Bamboo CLI

Setup

  • Clone https://github.com/pietgeursen/bamboo-rs
  • Checkout branch bamboo-commit-388bafe
  • $ cd bamboo-cli
  • cargo build --release
  • Maybe copy the binary into your bin folder so it's on your path and easier to use. $ cp ../target/release/bamboo-cli <somewhere>

Help

bamboo-cli --help

Generate a keypair

Maybe make a new dir to play around in. Then:

$ bamboo-cli generate-keys --public-key-file pk --secret-key-file sk

You can always get help for a subcommand like:

$ bamboo-cli generate-keys --help

Then you can check what your public key is as a hex string:

$ xxd -p pk | tr -d '\n'

Or as base64

$ base64 pk

Publish the first entry

Create a new file called payload_1 and write "hello world" in it. This is going to be the payload of our first entry in our feed.

Check the help for the publish command.

Then let's publish our first message:

$ bamboo-cli publish --is-start-of-feed --public-key-file pk --secret-key-file sk --payload-file payload_1 > entry_1

Decode an entry so we can inspect it

$ bamboo-cli decode entry_1

Verify an entry is valid

$ bamboo-cli verify --entry-file entry_1 --payload-file payload_1

Note that you can omit the payload if you want. This is part of supporting offchain content.

Publish new entries

This is slightly more complicated because we need to calculate the lipmaa number for the entry we're publishing.

If we want to publish the second entry, then calculate the lipmaa number like:

$ bamboo-cli lipmaa 2

And you should get 1.

So the lipmaa entry in this case will be entry_1

Try out publishing a new entry. You'll have to provide the --lipmaa-entry-file and the --previous-entry-file arguments this time.

Bonus fun: Post an entry to a "pub".

Go here: https://mighty-sands-24362.herokuapp.com/swagger/index.html

This is from https://github.com/pietgeursen/bamboo-rest-api which is deployed to Heroku.

Select the POST / route in swagger, then Try It Out

Encode your first entry as a hex string:

$ xxd -p entry_1 | tr -d '\n'

And copy the result without any weird trailing characters your terminal might print eg '%'

Paste it into swagger as the encodedEntry

Now do the same for the payload.

If that went ok, you should get a 200.

Now if you hit GET / in swagger you should see you public key as one of the authors in the array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment