I’m trying to figure out how to originate a new contract from within a dapp. I seem to have found what I am looking for here: https://tezostaquito.io/docs/originate
Here is the example code I am looking at, for convenience:
// import { TezosToolkit } from '@taquito/taquito';
// const Tezos = new TezosToolkit('https://jakartanet.ecadinfra.com');
// const genericMultisigJSONfile = require('./generic.json')
// generic.json is referring to Michelson source code in JSON representation
Tezos.contract
.originate({
code: genericMultisigJSONfile,
storage: {
stored_counter: 0,
threshold: 1,
keys: ['edpkuLxx9PQD8fZ45eUzrK3BhfDZJHhBuK4Zi49DcEGANwd2rpX82t'],
},
})
.then((originationOp) => {
println(`Waiting for confirmation of origination for ${originationOp.contractAddress}...`);
return originationOp.contract();
})
.then((contract) => {
println(`Origination completed.`);
})
.catch((error) => println(`Error: ${JSON.stringify(error, null, 2)}`));
However this appears to require the contract to be michelson source code in JSON representation. How can I convert my archetype smart contract into this format?
Or more broadly - am I taking the wrong approach here altogether? Is there an archetype specific tool or approach here?
For example, I am wondering if the storage parameter that plugs into contract.originate() will even to accept the custom archetype types from the "@completium/archetype-ts-types" library... ? (Because I haven't gotten past converting the smart contract into the right format I haven't been able to test this myself yet)
Any help is appreciated
--EDIT--
Just a note that I eventually found it easiest to use this command to generate the contract code as a json object already embedded in a javascript file: completium-cli generate javascript test.arl --json >> testJSONmich.js
In order to most easily update the storage, I used the instructions under 'option a' here: https://tezostaquito.io/docs/originate/.
This allows an ordinary javascript object to be passed in with the storage variables and initialising parameters.