contractCall

contractCall is a method of launcher sdk that allows developers to call any admin related methods on the contract. It also allows developers to read or modify any ERC information of the launcher contracts.

Parameter

Argumenttypedescription
methodNamestringthe name of the methods you want to call
argumentsany[]the list of arguments that need to be provided to the contract method when calling the
signerSigner?the signer instance to represent the account caller and is only required when calling the write method

Below is a list of admin methods that can be called through contractCall:

grantRole

grant role(e.g: ADMIN role) to the provided address

Arguments:

  • address: a string that represents the account address
  • role: a string generated from keccak256 hashing of constant "ADMIN_ROLE"
configurePresale

Initialize the presale contract fields after deployment of the presale contract

Arguments

  • startTime: string, a unix timestamp in terms of seconds of start time
  • endTime: string, a unix timestamp in terms of seconds of end time
  • withdrawAfterTime: string, a unix timestamp in terms of seconds of withdraw time
  • supply: string, a number string that represents contract supply
  • maxAmountPerBuyer: string, a number string that limits the max amount of presale token to be bought by each buyer
  • minInvestment: string, a number string that limits the min amount of presale token to be bought by each buyer
  • paymentMethods: string[], list of string that lists erc20 token addresses that can be used to buy persale token
  • tokenRate: Integer[][], list of exchange rate correspond to paymentMethods. Each exchange rate contains two integers that represents how much presale token can be exchanged with how much payment token
modifyPaymentMethods

Add or remove payment methods from the supported payment methods list stored in presale contract

Argument

  • paymentMethods: string[], list of erc20 token addresses that can be used to purchase presale token
  • tokenRate: Integer[][], list of exchange rate. Each exchange rate contains two Integers and correspond to the payment method at their index. If one of the two Integers is zero, then the corresponding payment method is removed
ownerWithdraw

Transfer the token stored inside this contract to feeReceiver. This action can only performed by contract owner, so you need to set the signer inside contractCall with the signer that has contract owner key

Argument

  • tokenAddress: string, address of the payment token or presale token
  • amount: string, amount of token to be transferred
ownerWithdrawAll

Transfer all of the specified token stored inside this contract to feeReceiver

Argument

  • tokenAddress: string, address of the payment token or presale token
setPaymentReceiver

Change the fee receiver address of the presale contract

Argument

  • walletAddress: string, the wallet address of the new fee receiver
removeFromWhitelist

Remove addresses from the presale contract if the whitelist is enabled. Only wallet address on the whitelist could buy or withdraw presale token

Argument

  • addresses: string[], list of wallet address on the current whitelist
addToWhitelist

Add addresses to the presale contract whitelist if the whitelist is enabled. Only wallet address on the whitelist could buy or withdraw presale token

Argument

  • addresses: string[], list of wallet addresses that is not on current whitelist
renounceRole

Revokes role from account

Argument

  • account: string, the wallet address
  • role: string, a string generated from keccak256 hashing of constant "ADMIN_ROLE"
revokeRole

Revokes role from the calling account.

Argument

  • account: string, the wallet address
  • role: string, a string generated from keccak256 hashing of constant "ADMIN_ROLE"

Example

const paymentReceiver = <YOUR_PAYMENT_RECEIVER>
const chainId = <CHAIN_ID>
const signer = new Wallet(CONTRACT_OWNER_PRIVATE_KEY, getDefaultProvider(chainId))
await presaleSdk.contractCall("setPaymentReceiver", [paymentReceiver], signer)