This is a contract to which you give the admin of your token denomination(s) from the TokenFactory module. Once this contract has that, it allows other contracts you/your DAO controls to mint tokens for your business logic needs (via a WasmMsg).
This makes it more flexible since multiple contracts can "mint" tokens on behalf of the contract admin :D
$RAC has slots & dice contracts. If every game they want to mint 1 RAC for you for playing, both slots and dice would need to be admin of the token-factory token to mint With this core contract, a single contract is an admin, then the DAO can whitelist both the dice and slots address to mint tokens on its behalf.
This way to mint $RAC natively, the dice contract would WasmMsg a mint to the core contract, to then give the user that token.
Add the following to your Cargo.toml
dependencies for a contract. Then view the Mint section of this document for how to implement it.
toml
[dependencies]
tokenfactory-types = { git = "https://github.com/CosmosContracts/tokenfactory-contracts" }
You can view an example of how to use this in the example contract or see the e2e test for a full example in bash.
Mainnet Store Code: TBD
```sh
FLAGS="--gas-prices 0.003ujuno --gas auto --gas-adjustment 1.3 --chain-id uni-6 --node https://juno-testnet-rpc.polkachu.com:443 --output json --from [key]"
junod tx tokenfactory create-denom abcde $FLAGS
junod tx wasm instantiate "###" {"allowedmintaddresses":[],"denoms":["factory/juno1./abcde"]} --label "tf-middlware" --admin [key] $FLAGS
junod tx tokenfactory change-admin factory/juno1./abcde juno1middlewarecontract $FLAGS
junod q tokenfactory denom-authority-metadata factory/juno1./abcde ```
You can then mint tokens via another contract using the following example
```rust // msg.rs - mint on behalf of the corefactoryaddress
pub enum ExecuteMsg {
MintTokens {
// You could save this in state.rs on initialize.
coretfmiddlewarecontract: String,
denoms: Vec
// contract.rs - execute
// Ensure you added the tokenfactory-types dependency use juno::junotokenfactorytypes::msg::ExecuteMsg::Mint;
ExecuteMsg::MintTokens { coretfmiddlewarecontract, denoms, toaddress, } => { let payload = Mint { address: toaddress, denom: denoms, }; let wasmmsg = WasmMsg::Execute { contractaddr: coretfmiddlewarecontract.tostring(), msg: tobinary(&payload)?, funds: vec![], };
Ok(Response::new()
.add_attribute("method", "execute_mint_tokens_from_other_contract")
.add_message(wasm_msg))
} ```