Granary

Granary

  • Docs
  • Tutorials
  • API

›Sandbox

Getting started

  • What & Why
  • Installation

API

  • CLI Commands
  • Configuration

Client

  • Using the client

Sandbox

  • Introduction
  • Activating a protocol

Contributing

  • Development environment
  • Updating the docs
  • Examples on how to contribute to Granary

Activating a protocol

Sandboxed node comes with exactly one block on the chain - the genesis block. You can check it out using the tezos-client:

granary client - rpc get "/chains/main/blocks/head"

At this moment, our chain runs a dummy economic protocol, called genesis. What we actually want, is to activate the latest protocol that's available on the live zeronet/alphanet/mainnet, otherwise basic features such as transfers between accounts, would not be possible.

Quick start (relatively quick)

⚠️ In the upcoming release the following process will be automated

# Import the activator secret key
granary client - import secret key "activator" "unencrypted:edsk31vznjHSSpGExDMHYASz45VZqXN4DPxvsa4hAyY8dHM28cZzp6"

# Create protocol_parameters.json in your project
{ 
    "bootstrap_accounts": [
        [ "edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav", "4000000000000" ]
    ],
    "time_between_blocks" : [ "1", "0" ],
    "blocks_per_roll_snapshot" : 4,
    "blocks_per_cycle" : 8,
    "preserved_cycles" : 2,
    "proof_of_work_threshold": "-1"
}

# Activate the desired protocol using the activator key
# You can find additional available protocols in the list below
granary client - activate protocol Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd with fitness 1 and key activator and parameters $PWD/protocol_parameters.json --timestamp $(TZ='AAA+1' date +%FT%TZ)

# Import a secret key for the account 
# specified in protocol_parameters.json's bootstrap_accounts
granary client - import secret key "bootstrap1" "unencrypted:edsk3gUfUPyBSfrS9CCgmCiQsTCHGkviBDusMxDJstFtojtc1zcpsh"

# Our bootstrapped account also has baking rights right away,
# so we bake a new block with the protocol activation
granary client - bake for "bootstrap1"

# Confirm that we have a new block with the new protocol
granary client - rpc get "/chains/main/blocks/head"

Available protocols

NameHash
AthensPt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd
BabylonPsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU

Who can activate protocols?

Activations on top of the genesis block/protocol, have to be signed by a private key, that belongs to the public key specified in .granary/node/sandbox.json as genesis_pubkey:

{
    "genesis_pubkey": "edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2"
}

Importing an activator account

Activator private key

This may change according to your sandbox.json's genesis_pubkey.

encrypted:edsk31vznjHSSpGExDMHYASz45VZqXN4DPxvsa4hAyY8dHM28cZzp6

Import the activator account

granary client - import secret key "activator" "unencrypted:edsk31vznjHSSpGExDMHYASz45VZqXN4DPxvsa4hAyY8dHM28cZzp6"

Verifying the account import

Public Key should match the genesis_pubkey from sandbox.json.

granary client - show address "activator" -S
Hash: tz1TGu6TN5GSez2ndXXeDX6LgUDvLzPLqgYV
Public Key: edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2
Secret Key: unencrypted:edsk31vznjHSSpGExDMHYASz45VZqXN4DPxvsa4hAyY8dHM28cZzp6

Protocol parameters

Protocol can be customized by a protocol_parameters.json file.

Notable configuration options

KeyDescriptionExample
bootstrap_accountsPublic key and an amount of XTZ available["edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav", "4000000000000"]

Example protocol_parameters.json

{ 
    "bootstrap_accounts": [
        [ "edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav", "4000000000000" ]
    ],
    "time_between_blocks" : [ "1", "0" ],
    "blocks_per_roll_snapshot" : 4,
    "blocks_per_cycle" : 8,
    "preserved_cycles" : 2,
    "proof_of_work_threshold": "-1"
}

Faucet

Once you've injected the protocol with a set of protocol parameters, you can simulate a faucet by transferring XTZ from one of the rich bootstrap accounts, to any account that you import to your client after activating the protocol.

⚠️ You will not be able to import accounts from the Alphanet faucet

# Import the bootstrapped account, if we haven't dont that yet
granary client - import secret key "bootstrap1" "unencrypted:edsk3gUfUPyBSfrS9CCgmCiQsTCHGkviBDusMxDJstFtojtc1zcpsh"

# Import a new account called 'alice'
granary client - import secret key "alice" "unencrypted:edsk39qAm1fiMjgmPkw1EgQYkMzkJezLNewd7PLNHTkr6w9XA2zdfo"

# Client will wait for the operation to be included into the chain, so we start it in the background with '&'
granary client - transfer 1000 from bootstrap1 to alice --burn-cap 0.257 &

# Bake a new block to include the transfer operation from above
granary client - bake for bootstrap1

# Outputs 1000 XTZ
granary client - get balance for alice
Last updated on 8/8/2019 by Unknown
← IntroductionDevelopment environment →
  • Quick start (relatively quick)
  • Available protocols
  • Who can activate protocols?
    • Importing an activator account
  • Protocol parameters
    • Notable configuration options
    • Example protocol_parameters.json
  • Faucet
Docs
APIConfig
Community
Stack OverflowProject ChatTwitter
More
GitHubStar
Facebook Open Source
Copyright © 2019 Stove Labs
Icons made by Freepik and Smashicons from www.flaticon.com is licensed by CC 3.0 BY
Terminal window by nikitahl