The BCM can use the init function on the InitMint contract to mint Beans through the diamondCut function, as Beanstalk does not have a native function to mint Beans to a particular address.
InitMint is deployed here:
InitMint | Address 0x077495925c17230E5e8951443d547ECdbB4925Bb | Etherscan
SPDX-License-Identifier: MIT */ pragma solidity =0.7.6; pragma experimental ABIEncoderV2; import "../../C.sol"; /** * @author Publius * @title InitMint mints Beans **/ contract InitMint { function init(address payee, uint256 amount) external { C.bean().mint(payee, amount); } } /* SPDX-License-Identifier: MIT */ pragma solidity =0.7.6; pragma experimental ABIEncoderV2; import "./interfaces/IBean.sol"; import "./interfaces/ICurve.sol"; import "./interfaces/IFertilizer.sol"; import "./interfaces/IProxyAdmin.sol"; import "./libraries/Decimal.sol"; /** * @author Publius * @title C holds the contracts for Beanstalk.
etherscan.io
This InitMint contract has been previously used in BIP-25 and BIP-27.
- BIP-25 Safe transaction
- BIP-27 Safe transaction
Table of Contents
- Table of Contents
- Format
- Encoding the Function Call
- Option 1: Online ABI Encoder
- Option 2: CLI through hardhat
Format
diamondCut transactions using InitMint should be formatted like so:
[
[],
0x077495925c17230E5e8951443d547ECdbB4925Bb,
encodedFunctionCall
]_diamondCutis left empty (only if no functions are changed)_initis set to theInitMintaddress_calldatais set to the encoded function call made toInitMint
Encoding the Function Call
Because the init function call is wrapped in a diamondCut, we need to encode the function calldata.
init has the following signature:
function init(address payee, uint256 amount) external;address payeeis the address to mint Beans touint256 amountis the amount of Beans to mint to the address—since Beans have 6 decimals, thepayeeamount needs to be multiplied by 1e6 (e.g., 1k beans = 1000000000)
Function calls can be encoded several ways:
- Online ABI Encoder
- CLI through
hardhat
Option 1: Online ABI Encoder
- Visit https://abi.hashex.org/.
- Click the “Auto-parse” tab.
- Paste in the following ABI for
InitMint: - Click “Parse”.
- Select
init(address,uint256)in the “Function” dropdown. - Enter the corresponding address in the Beans Minted section of the written Snapshot proposal into the
payeefield. - Enter the corresponding number of Beans in the Beans Minted section of the written Snapshot proposal into the
amountfield (remember to multiple by 1e6). - Use a site like https://www.diffchecker.com/text-compare/ to compare the encoded call data you generated with the encoded call data in the
diamondCutcall. - You may need to prepend to encoded data you got from the site with
0x.
[{"inputs":[{"internalType":"address","name":"payee","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"}]Option 2: CLI through hardhat
- Clone the Beanstalk repo and make sure
MAINNET_RPCin.envis set per How to Setup Environment. - Paste the following task into
hardhat.config.jsin theprotocoldirectory. - Set
<PAYEE_ADDRESS>the corresponding address in the Beans Minted section of the written Snapshot proposal. - Set
<PAYEE_AMOUNT>the corresponding number of Beans in the Beans Minted section of the written Snapshot proposal. - Enter the corresponding number of Beans in the Beans Minted section of the written Snapshot proposal into the
amountfield (remember to multiple by 1e6). - Run
npx hardhat encodeMintfrom theprotocoldirectory and copy the output in the terminal. - Use a site like https://www.diffchecker.com/text-compare/ to compare the encoded call data you generated with the encoded call data in the
diamondCutcall.
task('encodeMint', async function () {
const payee = '<PAYEE_ADDRESS>'
const amount = '<PAYEE_AMOUNT>'
const initMint = await ethers.getContractFactory('InitMint')
encodedFunctionCall = initMint.interface.encodeFunctionData('init', [payee, amount])
console.log(encodedFunctionCall)
})