Skip to content

Instantly share code, notes, and snippets.

@goral09
Created October 6, 2018 15:39
Show Gist options
  • Save goral09/53333eb5f56366915a41e0265ed5713c to your computer and use it in GitHub Desktop.
Save goral09/53333eb5f56366915a41e0265ed5713c to your computer and use it in GitHub Desktop.
RChain registry interaction
new register(`rho:registry:insertArbitrary`), out(`rho:io:stdout`), myContract, ret in {
  contract myContract(arg1, arg2) = { out!(("These are the args: ", arg1, arg2)) } |
  register!(bundle+{*myContract}, *ret) |
  for (@urn <- ret) {
    out!(("My contract is located at this URN: ", urn))
  }
}

To look up the contract at the id in a different deployment:

new lookup(`rho:registry:lookup`), ret in {
   lookup!(`rho:id:ugft58531rdrupt66fux6he4ki71o9bp4nzcede5jbfeiwcktp3g35`, *ret) |
   for (myContract <- ret) {
     myContract!(1, 2)
   }
}

Storing a contract at a public key is similar:

new register(`rho:registry:insertSigned`), out(`rho:io:stdout`), myContract, ret in {
  contract myContract(arg1, arg2) = { out!(("These are the args: ", arg1, arg2)) } |
  register!(<public key>, (<nonce>, bundle+{*myContract}), <signature>, *ret) |
  for (@urn <- ret) {
    out!(("My contract is located at this URN: ", urn))
  }
}

The nonce is an integer; to replace what is stored at the public key, increase the nonce. The signature is over the tuple (, ).

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