TokenFactory Core (middleware)

crates.io

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

Example Use Case

$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.


Rust Dependency

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] juno-tokenfactory-types = { git = "https://github.com/CosmosContracts/tokenfactory-contracts" }

or from crates.io - https://crates.io/crates/juno-tokenfactory-core

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.


Chain Setup

Mainnet Store Code: TBD

```sh

for uni-6 TESTNET

update [key] here to be your local wallet's key or your wallet's address

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]"

create a tokenfactory denomination via the CLI.

junod tx tokenfactory create-denom abcde $FLAGS

factory/juno1......./abcde is your new denom

upload this contract (skip if you use the mainnet code)

junod tx wasm store artifacts/junotokenfactorycore.wasm $FLAGS

Initialize this contract

You may want to set this as a normal admin initially before changing its admin to a DAO

junod tx wasm instantiate "###" {"allowedmintaddresses":[],"denoms":["factory/juno1./abcde"]} --label "tf-middlware" --admin [key] $FLAGS

Get the middleware contract address here

Transfer ownership of the token to the contract

junod tx tokenfactory change-admin factory/juno1./abcde juno1middlewarecontract $FLAGS

Ensure the juno1middlewarecontract now has the admin role

junod q tokenfactory denom-authority-metadata factory/juno1./abcde ```

How To Contract Mint

You can then mint tokens via another contract using the following example

```rust // msg.rs - mint on behalf of the corefactoryaddress

[cw_serde]

pub enum ExecuteMsg { MintTokens { // You could save this in state.rs on initialize. coretfmiddlewarecontract: String, denoms: Vec, toaddress: String, }, }

// 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))

} ```