# Testnet Access and Javascript SDK examples

**URL:** <https://forum.flow.com/t/testnet-access-and-javascript-sdk-examples/667>\
**Category:** Flow Go SDK\
**Tags:** flow-sdk-go\
**Created:** [December 13, 2020, 7:09pm UTC](https://forum.flow.com/t/testnet-access-and-javascript-sdk-examples/667 "2020-12-13T19:09:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![unlocked](https://avatars.discourse-cdn.com/v4/letter/u/3be4f8/32.png) [@unlocked](https://forum.flow.com/u/unlocked)\
**Post date:** [December 13, 2020, 7:09pm UTC](https://forum.flow.com/t/testnet-access-and-javascript-sdk-examples/667/1 "2020-12-13T19:09:25Z")

</div>

Below was the original question

> Hello, I found this on the onflow javascript sdk example. Is this up to date? I read on the onflow website that in order to deploy to testnet I needed to create an account on Faucet.
> 
> [![](https://us1.discourse-cdn.com/flex022/uploads/flow/original/1X/3491fd128b4449aa28309b37ff4ea2693e21f542.png)](https://cdn.discordapp.com/attachments/621847426201944074/787740207113044000/Screen_Shot_2020-12-13_at_12.57.00_PM.png)
> 
> When I use Blocto it doesn’t seem to connect as well
> 
> Also, the example listed here [https://docs.onflow.org/guides/dapp-deployment/testnet-deployment/](https://docs.onflow.org/guides/dapp-deployment/testnet-deployment/) when using Testnet is with the Go SDK. Is there a Javascript example as well? Also, is there a built out example of how to deploy contracts in Javascript SDK? Thanks again

---

<div class="post-metadata">

**Author:** ![unlocked](https://avatars.discourse-cdn.com/v4/letter/u/3be4f8/32.png) [@unlocked](https://forum.flow.com/u/unlocked)\
**Post date:** [December 13, 2020, 7:10pm UTC](https://forum.flow.com/t/testnet-access-and-javascript-sdk-examples/667/2 "2020-12-13T19:10:38Z")

</div>

@Tim @Mackenzie probably can share additional info on new Testnet access documentation  
@JeffreyDoyle or @qvvg might be able to help with Javascript SDK examples to deploy contracts to Testnet

---

<div class="post-metadata">

**Author:** ![jacobtucker](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@jacobtucker](https://forum.flow.com/u/jacobtucker)\
**Post date:** [December 13, 2020, 7:33pm UTC](https://forum.flow.com/t/testnet-access-and-javascript-sdk-examples/667/3 "2020-12-13T19:33:31Z")

</div>

Thanks unlocked. All of my questions still stand, but my biggest concern is that last part about deploying contracts in Javascript now. When I was a part of the bootcamp during the summer it was done the same way a transaction was sent. Now it looks different because you can deploy multiple contracts to 1 account and I keep getting an error message about “setCode.” I tried looking here [Contracts | Cadence](https://docs.onflow.org/cadence/language/contracts/#deploying-updating-and-removing-contracts) but it’s too confusing for me because I can’t find a Javascript example.

My end goal is really just to deploy a contract that mints test NFTs on the testnet, so whatever would help get me there is great hahahah. Thanks again 🙂

---

<div class="post-metadata">

**Author:** ![Mackenzie](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@Mackenzie](https://forum.flow.com/u/Mackenzie)\
**Post date:** [December 15, 2020, 3:41pm UTC](https://forum.flow.com/t/testnet-access-and-javascript-sdk-examples/667/4 "2020-12-15T15:41:00Z")

</div>

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:

```auto
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:

```auto
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!

---

<div class="post-metadata">

**Author:** ![qvvg](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/qvvg/32/78_2.png) [@qvvg](https://forum.flow.com/u/qvvg)\
**Post date:** [December 15, 2020, 4:28pm UTC](https://forum.flow.com/t/testnet-access-and-javascript-sdk-examples/667/5 "2020-12-15T16:28:41Z")

</div>

This repo might be of use, its up to date as of yesterday. : [https://github.com/orodio/flow-node-deploy-contract-example](https://github.com/orodio/flow-node-deploy-contract-example)

---

<div class="post-metadata">

**Author:** ![jacobtucker](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@jacobtucker](https://forum.flow.com/u/jacobtucker)\
**Post date:** [December 15, 2020, 4:52pm UTC](https://forum.flow.com/t/testnet-access-and-javascript-sdk-examples/667/6 "2020-12-15T16:52:13Z")

</div>

Thank you! That helped me very much in deploying a Contract! Now I am trying to deploy a contract to an account using the Testnet and I can’t seem to get it to work. This link [https://docs.onflow.org/guides/dapp-deployment/testnet-deployment/#getting-started-on-testnet](https://docs.onflow.org/guides/dapp-deployment/testnet-deployment/#getting-started-on-testnet) suggests using this command using the Flow CLI:

```auto
flow accounts create \
  --host access.devnet.nodes.onflow.org:9000 \
  --signer testnet \
  --code MyContract.cdc

```

However it returns an error everytime that the code flag doesn’t exist. I tried updating the CLI and everything. I’m not quite sure what to make of this. Thanks for your help again.

---

<div class="post-metadata">

**Author:** ![bastian](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/bastian/32/183_2.png) [@bastian](https://forum.flow.com/u/bastian)\
**Post date:** [December 15, 2020, 7:39pm UTC](https://forum.flow.com/t/testnet-access-and-javascript-sdk-examples/667/7 "2020-12-15T19:39:07Z")

</div>

Hi Jacob!

We’ve just recently updated the CLI to support multiple contracts per account.

Please update to CLI v0.12 (by reinstalling the CLI, i.e. running the installation command you used again).

The `--code` flag has been replaced by the `--contract` flag, so if you have a contract `contract MyContract { ... }` in a file `MyContract.cdc`, then:

`--contract MyContract:MyContract.cdc`

should work.
