In this How-To guide, we will demonstrate how you can set the spending limits for masterchef contracts on your tokens on the Polygon mainnet.
Changing the maximum spending limit for masterchef smart contracts #
In this example, we use both PolyBull Finance’s BULL token and masterchef smart contracts.
Step 1. Open the token’s smart contract
Go to Polygon (MATIC) Blockchain Explorer and enter the token’s smart contract address. In our case, we use the smart contract address of BULL: 0x138B9C072879219CD6Ef2D6d9E0D179B3396F07b.
Step 2. Open the write contract tab
Once the token smart contract is loaded, click on the tab called “write contract” and connect your web3 wallet by clicking the connect wallet link.
Step 3. Enter the farms’ masterchef
Look for the approve section in the contract. Enter the farms’ masterchef smart contract address in the “spender (address)” section. In this example, we use the masterchef address of PolyBull Finance: 0x2e47630f1a7807b596267361f9DD4C534632Ae98.
Step 4. Enter the amount of tokens that the masterchef is allowed to spend
Fill in the amount of tokens that the masterchef is allowed to spend in the “amount (uint256)” line. In this example, we need to fill in a maximum amount of BULL tokens. Keep in mind that every token on the Ethereum blockchain uses a different set amount of decimals: if we want a maximum of 20 BULL to be spend by the masterchef, we need to fill in 20^18, which is the value 20 plus 18 additional zeros.
In order to check the amount of decimals for a token on the Polygon mainnet, go to the tab “Read Contract” and scroll down until you reach the section “decimals”, which shows the amount of decimals needed for the token.
Step 5. Approve or edit the permission
After filling in both lines, click the “write” button. Your web3 wallet will now pop up with the request to confirm the permission.
If you want to change the spending limit, click “Edit”. Your web3 wallet will now ask you to set a custom spending limit or to give the smart contract permission to spend an unlimited amount of your token.
Once satisfied with the spending limit, click confirm.
Well done! You have successfully set a spending limit for your token(s)! Make sure that after interacting with the masterchef contract, you revoke its permissions. If you are not sure how to do this, please read our article.
Conclusión #
You should now be able to set, edit and change token spending limits on the Polygon mainnet.