0

I would like to call the stake entry point of a Plenty contract. I only have access to the Michelson source code.

Here is my current non-working code in Typescript with Beacon-SDK (inspired by this example).

import { DAppClient, TezosOperationType } from "@airgap/beacon-sdk";    

const PLENTYtoPLENTY = 'KT1QqjR4Fj9YegB37PQEqXUPHmFbhz6VJtwE'
const dAppClient = new DAppClient({ name: 'Plenty staker' })

const activeAccount = await dAppClient.getActiveAccount()
if (!activeAccount) {
    const permissions = await dAppClient.requestPermissions()
}

const ops = new Array(1).fill(0).map((_, i) => {
  return {
    kind: TezosOperationType.TRANSACTION,
    amount: "0",
    destination: PLENTYtoPLENTY,
    parameters: {
      entrypoint: "stake",
      value: 
      {
        stake: "10000"
      },
    },
  }
})

console.log('ops', ops[0])
try {
    const result = await dAppClient.requestOperation({
        operationDetails: ops as any,
    });

    console.log('result', result)
}  catch (error) {
  console.log(
    `The contract call failed and the following error was returned:`,
    error?.data[1]?.with?.string
  );
}

I get this error : "Parameters Invalid Some of the parameters you provided are invalid and the request could not be completed. Please check your inputs and try again." I assume the lines

      value: 
      {
        stake: "10000"
      },

are not correct. How can I know what parameter name I shall use? (also tried "prim" and "int")

4
  • Have you tried value: 10000 ? Also, the second link in your post is broken. – arvidj Jun 14 at 8:37
  • Or maybe int: 10000, or int: "10000". I find the documentation of Beacon confusing. If you can find either the michelson code of the contract called here: docs.walletbeacon.io/guides/simple-contract-call or the documentation for what's given to requestOperation I could probably help more. – arvidj Jun 14 at 8:42
  • Thanks. I corrected the second link. I tried several combinations of integer or string, pair or value but with no luck. – Clement J. Jun 14 at 10:49
  • Did you try value: { int : "10000" } ? It seems that: – arvidj Jun 14 at 12:05
1

Did you try value: { "int" : "10000" }?

It seems that:

  • the field value in parameters should be micheline (seeing how Unit is expressed)
  • the entrypoint %stake has type nat (the linked contract says (nat %stake) in the parameter type)
  • the Micheline encoding of the nat 10000 is {"int": "10000"} (this can be verified by the command $ ./tezos-client -mode mockup convert data '10000' from Michelson to json --type 'nat').
13
  • That would indeed make sens but I have again the same error. – Clement J. Jun 14 at 13:21
  • Hmm, I'm confused. Could you make a small minimal example and post it on the Beacon playground? – arvidj Jun 14 at 13:46
  • 1
    Also, do you know if it possible to get some debug information from the Beacon SDK. For instance, it would be interesting to see the generated RPC calls. – arvidj Jun 14 at 13:46
  • I added a link to a Beacon playground in the second paragraph. – Clement J. Jun 14 at 14:34
  • If from the playground I run with Spire rather than Kukai, I have some sort of debug information including the following; "kind": "temporary", "id": "proto.009-PsFLoren.michelson_v1.script_rejected", "location": 905, "with": { "string": "FA1.2_NotAllowed" – Clement J. Jun 14 at 18:42
1

I would like to clarify some of the beacon behavior.

The main responsibility of beacon is establishing and maintaining a communication channel between a dApp and a wallet. Beacon itself does NOT do any type checking or error handling regarding the contents of the tezos operations. The operations are sent to the other side as is, without any changes or error correction.

The beacon-sdk doesn't connect to an RPC, so it can't do any type checking on your inputs. If you want that, then you will have to use taquito, which abstracts a lot of the complexity and makes it easier to do contract calls.

After a request is received on the wallet side, the wallet takes over and processes the message. Any error that happens on the wallet side must be handled and displayed by the wallet. If this is not the case, an issue should be raised with the respective wallet. The beacon-sdk provides a set of error messages that can be returned to the dApp. One of them also allows the wallet to attach the error that was returned by the RPC so dApps can show some meaningful information (eg. fail with).

I will update the beacon docs, specifically the simple-contract-call page, to make this clearer.

1
  • Thanks for the clarification. – Clement J. Jun 23 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.