6

I have been testing and a lot of the docs refer to deploying to a local node only. How we can deploy a contract to the jungle testnet?

1

3 Answers 3

3

Here's an example of how to deploy to a testnet (assuming you've already set up the wallet and accounts). In this example we'll deploy the hello contract to the helloworld54 account on the CryptoKylin testnet:

cd hello/

touch hello.cpp 

eosiocpp -o hello.wasm hello.cpp
eosiocpp -g hello.abi hello.cpp

cd ..

# deploy
cleos -u http://api.kylin.alohaeos.com set contract helloworld54 hello/ -p helloworld54@active

# call contract action
cleos -u http://api.kylin.alohaeos.com push action helloworld54 hi '["bob"]' -p helloworld54@active
# >> Hello, bob 

hello.cpp

#include <eosiolib/eosio.hpp>
#include <eosiolib/print.hpp>
using namespace eosio;

class hello : public eosio::contract {
  public:
      using contract::contract;

      /// @abi action
      void hi( account_name user ) {
         print( "Hello, ", name{user} );
      }
};

EOSIO_ABI( hello, (hi) )

Some things to note:

You have to create a new account for every new contract that you deploy. An account can have 0 or 1 contracts. To create an account you have to stake at least 1 EOS. You can use the testnet faucet to get free EOS.

1

If you've been using cleos in the docs, cleos uses the -u or --url switch to specify the endpoint used to interact with when deploying or interacting with a contract.

Instead of referencing a local node like -u http://localhost:8888 you can instead reference a Jungle Net endpoint or even main net endpoint when trying to interact with a different chain.

Keep in mind you'll require an account on each of these chains and keys imported for cleos to work OK.

0
0

When using cleos use - u with the url of the test net

Your Answer

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

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