1

I would like to deploy my smart contract but I don't know what to put as parameters in the storage (I'm new to tezos). Thank you very much to those who will take the time to help me :)

//FA2
'(pair (pair (pair (address %admin) (big_map %ledger nat address))
            (pair (big_map %metadata string bytes) (nat %next_token_id)))
      (pair (pair (big_map %operators (pair address (pair address nat)) unit)
                  (big_map %reverse_ledger address (list nat)))
            (big_map %token_metadata nat (pair (nat %token_id) (map %token_info string bytes)))))' ;

//FA2
'(pair (pair (pair { Elt "tz1i3veHnR4ogcwKmgugcqnunTmTYP8s8ZAr" } { Elt 1 "tz1i3veHnR4ogcwKmgugcqnunTmTYP8s8ZAr" })
            (pair { Elt "" 0x68747470733a2f2f676973742e67697468756275736572636f6e74656e742e636f6d2f6f7269616e6131332f36663138333737353065366562383163646434666633363230663738613133322f7261772f653238396663353037326235613931353134383936376239613433333765313835343731363561322f636f6e74726163745f6d6574612e6a736f6e } { 0 2 }))
      (pair (pair { Elt (pair "tz1i3veHnR4ogcwKmgugcqnunTmTYP8s8ZAr" "tz1i3veHnR4ogcwKmgugcqnunTmTYP8s8ZAr" 1) unit }
                  { Elt "tz1i3veHnR4ogcwKmgugcqnunTmTYP8s8ZAr" (list nat)) }
            { Elt 0 (pair 1 { Elt "" 0x68747470733a2f2f676973742e67697468756275736572636f6e74656e742e636f6d2f6f7269616e6131332f35313763373231396531383639333938613765666631343335623862653237392f7261772f326337336132613564353365626466313662633864623831643837343236353964323763646462332f6e66745f6d6574612e6a736f6e)))) }' ;

my deploy.ts file:

import { TezosToolkit } from '@taquito/taquito'
import { importKey } from '@taquito/signer'
import * as fs from 'fs';

const provider = 'https://rpc.hangzhou.tzstats.com'

async function deploy() {
 const tezos = new TezosToolkit(provider)
 await importKey(
 tezos,
  '[email protected]', //mail
  'ZSrbDk3Nzf', //password
  [
    "sky",
    "inquiry",
    "build",
    "man",
    "aunt",
    "topic",
    "pattern",
    "image",
    "giant",
    "burger",
    "shock",
    "banner",
    "safe",
    "initial",
    "big"
].join(' '),
'My Secret' //private key
)

try {
const op = await tezos.contract.originate({
  //smart contract code
  code: JSON.parse(fs.readFileSync("./nft2.json").toString()),
  //storage state
  init: '(Pair (Pair (Pair "tz1i3veHnR4ogcwKmgugcqnunTmTYP8s8ZAr" { Elt 1 "tz1i3veHnR4ogcwKmgugcqnunTmTYP8s8ZAr" }) (Pair { Elt "" 0x68747470733a2f2f676973742e67697468756275736572636f6e74656e742e636f6d2f6f7269616e6131332f36663138333737353065366562383163646434666633363230663738613133322f7261772f653238396663353037326235613931353134383936376239613433333765313835343731363561322f636f6e74726163745f6d6574612e6a736f6e } 2)) (Pair (Pair { 1 1 } { Elt "tz1i3veHnR4ogcwKmgugcqnunTmTYP8s8ZAr" 1 }) { Elt 1 (Pair 1 { Elt "" 0x68747470733a2f2f676973742e67697468756275736572636f6e74656e742e636f6d2f6f7269616e6131332f35313763373231396531383639333938613765666631343335623862653237392f7261772f326337336132613564353365626466313662633864623831643837343236353964323763646462332f6e66745f6d6574612e6a736f6e }) }))'
})
//beginning to deploy
console.log('Awaiting confirmation...')
const contract = await op.contract()
//deployment report: amount of used gas, storage state
console.log('Gas Used', op.consumedGas)
console.log('Storage', await contract.storage())
//operation hash one can use to find the contract in the explorer
console.log('Operation hash:', op.hash)
} catch (ex) {
console.error(ex)
 }
} 
deploy()

But the parameters that I provide in the deploy file, in my init variable are not good, I am trying to understand which parameters to pass.

Error : enter image description here

1

1 Answer 1

1

You can use michelson-sdk to generate the Michelson values (Micheline or Michelson JSON).

// Micheline:  (Pair (Pair (Pair "tz1i3veHnR4ogcwKmgugcqnunTmTYP8s8ZAr" { Elt 1 "tz1i3veHnR4ogcwKmgugcqnunTmTYP8s8ZAr" }) (Pair { Elt "" 0x68747470733a2f2f676973742e67697468756275736572636f6e74656e742e636f6d2f6f7269616e6131332f36663138333737353065366562383163646434666633363230663738613133322f7261772f653238396663353037326235613931353134383936376239613433333765313835343731363561322f636f6e74726163745f6d6574612e6a736f6e } 2)) (Pair (Pair {  } { Elt "tz1i3veHnR4ogcwKmgugcqnunTmTYP8s8ZAr" { 1 } }) { Elt 1 (Pair 1 { Elt "" 0x68747470733a2f2f676973742e67697468756275736572636f6e74656e742e636f6d2f6f7269616e6131332f35313763373231396531383639333938613765666631343335623862653237392f7261772f326337336132613564353365626466313662633864623831643837343236353964323763646462332f6e66745f6d6574612e6a736f6e }) })) 

import {
  Record,
  Address,
  Nat,
  Big_map,
  String,
  Bytes,
  Map
} from "@tezwell/michelson-sdk/literal";

const storage = Record(
  {
    admin: Address("tz1i3veHnR4ogcwKmgugcqnunTmTYP8s8ZAr"),
    ledger: Big_map([
      [Nat(1), Address("tz1i3veHnR4ogcwKmgugcqnunTmTYP8s8ZAr")]
    ]),
    metadata: Big_map([
      [
        String(""),
        Bytes(
          "0x68747470733a2f2f676973742e67697468756275736572636f6e74656e742e636f6d2f6f7269616e6131332f36663138333737353065366562383163646434666633363230663738613133322f7261772f653238396663353037326235613931353134383936376239613433333765313835343731363561322f636f6e74726163745f6d6574612e6a736f6e"
        )
      ]
    ]),
    next_token_id: Nat(2),
    operators: Big_map([]),
    reverse_ledger: 
       Big_map([[Address("tz1i3veHnR4ogcwKmgugcqnunTmTYP8s8ZAr"), List([Nat(1)])]
    ]),
    token_metadata: Big_map([
      [
        Nat(1),
        Record({
          token_id: Nat(1),
          token_info: Map([
            [
              String(""),
              Bytes(
                "0x68747470733a2f2f676973742e67697468756275736572636f6e74656e742e636f6d2f6f7269616e6131332f35313763373231396531383639333938613765666631343335623862653237392f7261772f326337336132613564353365626466313662633864623831643837343236353964323763646462332f6e66745f6d6574612e6a736f6e"
              )
            ]
          ])
        })
      ]
    ])
  },
  [
    [
      ["admin", "ledger"],
      ["metadata", "next_token_id"]
    ],
    [["operators", "reverse_ledger"], "token_metadata"]
  ]
);

console.log("Micheline: ", storage.toMicheline());
console.log("Michelson JSON: ", storage.toJSON());

I can help with further questions about using the package, let me know if the documentation is not clear enough.

5
  • Thank you very much for your answer :)
    – oriana
    Feb 16, 2022 at 10:29
  • I updated my question
    – oriana
    Feb 16, 2022 at 10:56
  • Can you share the "nft2.json" file? The screenshot above does not give enough information. Feb 16, 2022 at 11:22
  • "reverse_ledger" value was wrong. I updated my answer. Feb 16, 2022 at 11:27
  • 1
    Thank you so much ! it works ! :)
    – oriana
    Feb 16, 2022 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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