Skip to main content

Pre-deployed Contract

Learn how to easily receive fungible tokens without doing any software development by using a readily-available FT smart contract.


Prerequisitesโ€‹

To complete this tutorial successfully, you'll need:


Using the FT contractโ€‹

Create a new testnet account using the web wallet.

Setupโ€‹

Log in to your newly created account with near-cli-rs by running the following command in your terminal:

near account import-account using-web-wallet network-config testnet

Set an environment variable for your account ID to make it easy to copy and paste commands from this tutorial:

export NEARID=YOUR_ACCOUNT_NAME
note

Be sure to replace YOUR_ACCOUNT_NAME with the account name you just logged in with including the .testnet.

Test that the environment variable is set correctly by running:

echo $NEARID

Receiving Fungible Tokensโ€‹

NEAR has deployed a new Fungible Token contract to the account ft.predeployed.examples.testnet which allows users to freely receive some gtNEAR - a new fungible token aimed to promote the power of teamwork! Each gtNEAR is equal to 1e24 yocto-gtNEAR similar to how 1 $NEAR is equal to 1e24 yoctoNEAR.

Using this pre-deployed contract, let's get some gtNEAR!

Start by calling the method ft_mint which is a custom function implemented on this contract in order to send your account some gtNEAR! The following command will send 0.01 gtNEAR to your account.

near call ft.predeployed.examples.testnet ft_mint '{"account_id": "'$NEARID'", "amount": "10000000000000000000000"}' --gas 100000000000000 --accountId $NEARID --networkId testnet
Example response:

Log [ft.predeployed.examples.testnet]: EVENT_JSON:{"standard":"nep141","version":"1.0.0","event":"ft_mint","data":[{"owner_id":"benjiman.testnet","amount":"10000000000000000000000","memo":"FTs Minted"}]}
Transaction Id Fhqa8YDLKxnxM9jjHCPN4hn1w1RKESYrav3kwDjhWWUu
To see the transaction in the transaction explorer, please open this url in your browser
https://testnet.nearblocks.io/txns/Fhqa8YDLKxnxM9jjHCPN4hn1w1RKESYrav3kwDjhWWUu
''

To view tokens owned by an account you can call the FT contract with the following near-cli command:

near view ft.predeployed.examples.testnet ft_balance_of '{"account_id": "'$NEARID'"}' --networkId testnet
Example response:

'10000000000000000000000'

Congratulations! You just received your first Team Tokens on the NEAR blockchain! ๐ŸŽ‰

๐Ÿ‘‰ Now try going to your NEAR Wallet and view your FTs in the "Balances" tab. ๐Ÿ‘ˆ

Pre-deployed Contract

The contract used in this section has been modified such that you can infinitely get gtNEAR by calling ft_mint. This function is not part of the FT standards and has been implemented for the purpose of this tutorial.


Final remarksโ€‹

This basic example illustrates all the required steps to call an FT smart contract on NEAR and receive your own fungible tokens.

Now that you're familiar with the process, you can jump to Contract Architecture and learn more about the smart contract structure and how you can build your own FT contract from the ground up.

Happy minting! ๐Ÿช™

Versioning for this article

At the time of this writing, this example works with the following versions:

  • near-cli-rs: 0.11.0
Was this page helpful?