Deploying contracts from JavaScript is done the same way you did it in the bootcamp, but with a small change to the Cadence code you use in the transaction itself.
Previously, you would have used a transaction like this:
const CODE =
`transaction(code: String) {
prepare(acct: AuthAccount) {
acct.setCode(code.decodeHex())
}
}`
Now that accounts have multi-contract support, your transaction should look something like this:
const CODE =
`transaction(code: String) {
prepare(acct: AuthAccount) {
acct.contracts.add(
name: "Test",
code: code.decodeHex(),
message: "I'm a new contract in an existing account"
)
}
}`
Hi Jacob, I think the error you’re getting about setCode
is happening because @onflow/fcl
's ‘stored interactions’ have not been updated with this new transaction code. You can still send the transaction without using a ‘stored interaction’ in the meantime. Multi-contract support in Cadence is a recent addition, and we’re working on bringing all the tooling up-to-date.
It’s true that the documentation is lacking good JavaScript examples, at the moment. We’re also working on making a guide for JavaScript developers to follow, using the latest Cadence features!