Test Tokens

Deploy and interact with tokens easily using simple function calls.

Creating a Test Token

Test tokens are regular ERC20s with a public function that allows the owner to mint them at will.

reaper.deployTestToken(name: string, symbol: string) => (address:string)

Example of a Test Token deployment utilizing the BigGas constant to ensure execution:

const testToken = await reaper.deployTestToken("Reaper Test Token", "RTT", reaper.BigGas);
console.log("Test Token Address: " +testToken);

> Test Token Address: 0xB19b478543D828131edCdCe33891d09C80e09341

Single-owner mint functions are not recommended for production, as they are highly centralized and generally insecure.

Viewing Your Token's Metadata

Return an object which contains all relevant metadata for your test token or any other ERC20.

reaper.getTokenMetadata(tokenAddress: string) => ({ name:string, symbol:string, decimals: uint, totalSupply: uint, owner: string })

Fetching metadata for the above test token deployment:

const metadata = await reaper.getTokenMetadata(testToken);
console.log("Token Name: " +metadata.name);
console.log("Token Supply: " +metadata.totalSupply);

> Token Name: Reaper Test Token
> Token Supply: 0

Minting Test Tokens

ReaperSDK's built-in test token allows the owner to mint infinitely to any address.

reaper.mintTestToken(tokenAddress: string, userAddress: string, amount: uint) => (userBalance:BigNumber)

Minting to multiple addresses with Reaper's parseToken function and viewing their updated balances:

const user1 = "0x8B4441E79151e3fC5264733A3C5da4fF8EAc16c1";
const user2 = "0x66e17197A8e0BE5D3161337Bf881c2364d0c56E8";

let user1Balance = await reaper.mintTestToken(testToken, user1, await reaper.parseToken(100, testToken));
let user2Balance = await reaper.mintTestToken(testToken, user2, await reaper.parseToken(10000, testToken));
console.log("User 1 Balance: " +user1Balance);
console.log("User 2 Balance: " +user2Balance);
  
> User 1 Balance: 100
> User 2 Balance: 10000

Viewing a User's Token Balances

Check any user's Fantom or ERC20 balance with simple inputs.

reaper.getUserBalance(userAddress:string, [tokenAddress:string]) => (userBalance:BigNumber)

  const user1 = "0x8B4441E79151e3fC5264733A3C5da4fF8EAc16c1";

  await reaper.mintTestToken(testToken, user1, await reaper.Ether(450, testToken));

  let fantomBalance = await reaper.getUserBalance(user1);
  let tokenBalance = await reaper.getUserBalance(user1, testToken);
  
  console.log("User One Fantom Balance: " +fantomBalance);
  console.log("User Two Test Token Balance: " +tokenBalance);
  
  > User One Fantom Balance: 102.85817804062937
  > User Two Test Token Balance: 450

Approving Tokens

We took the thinking out of approvals with a simple maximum approval for any token input array. The second input can be a single address or an array of addresses - single addresses will be formatted into an array of length 1.

reaper.approveMax(spenderAddress:string, tokenAddresses:string[ ]) => "success"

Only use maximum approvals for contracts you trust.

Last updated