Skip to content

Latest commit

 

History

History

contract-simple-ts

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Cross-Contract Hello Contract

The smart contract implements the simplest form of cross-contract calls: it calls the Hello NEAR example to get and set a greeting.


Quickstart

  1. Make sure you have installed node.js >= 16.
  2. Install the NEAR CLI

1. Build and Test the Contract

You can automatically compile and test the contract by running:

# To solely build the contract
npm run build

# To build and execute the contract's tests
npm run test

2. Create an Account and Deploy the Contract

You can create a new account and deploy the contract by running:

near create-account <your-account.testnet> --useFaucet

near deploy <your-account.testnet> ./build/cross_contract.wasm init '{"hello_account":"hello.near-example.testnet"}' 

3. CLI: Interacting with the Contract

To interact with the contract through the console, you can use the following commands

# Get message from the hello-near contract
# Replace <your-account.testnet> with your account ID
near call <your-account.testnet> query_greeting --accountId <your-account.testnet>

# Set a new message for the hello-near contract
# Replace <your-account.testnet> with your account ID
near call <your-account.testnet> change_greeting '{"new_greeting":"XCC Hi"}' --accountId <your-account.testnet>

Useful Links