Open emlautarom1 opened 9 months ago
It's important to note what we actually are looking for: a unique SmartContract
that mints a single, untransferable token per user given some input which has to satisfy a predicate.
Another thing we've tried is removing all permission configuration from the SmartContract
:
import { SmartContract, UInt64, method } from "o1js";
export const MINTEXAMPLE_TOKEN_NAME = "ZKEML"
export class MintExample extends SmartContract {
@method submitSecret(secret: UInt64) {
secret.assertEquals(UInt64.from(420));
this.token.mint({
address: this.sender,
amount: 1,
});
}
}
This also results in the same Invalid fee excess
error
@emlautarom1 you are creating a new account because one account can hold only one kind of token. So your transaction is creating the account with public key = this.sender
, tokenId = zkApp.token.id
.
check out our docs on token accounts: https://docs.minaprotocol.com/zkapps/o1js/custom-tokens#token-accounts
According to the docs:
Suppose a token account is being created for the first time. In that case, an account creation fee must be paid similarly to creating a new standard account.
In this case then a token account is created from the existing senderAccount
, and I would assume that senderAccount
should pay the account creation fees using MINA. If so, then why I cannot pay the creation fees? Or is it that I need to explicitly list the fee as part of the transaction (something like the following)?
const txn = await Mina.transaction(senderAccount, () => {
zkApp.submitSecret(UInt64.from(420));
// Explicitly pay fees for account creation of `senderAccount` for a specific Custom Token
senderAccount.payFee(Mina.accountCreationFee()); // not valid code
});
I also found this example which pays fees for the account creation, but it's part of the SmartContract
code:
This does not apply to our use case because then the SmartContract
would be paying the fees (as far as I understand).
@emlautarom1 yes fee paying is an explicit action. the example snippet in your link works also when replacing this
with any AccountUpdate
.
There's also a single command to create an account update which pays an account creation fee:
AccountUpdate.fundNewAccount(senderAccount);
We're currently experimenting with Custom Tokens (https://docs.minaprotocol.com/zkapps/o1js/custom-tokens) as a possible solution for on-chain state. Our goal is to have a single
SmartContract
which mints a special token per user, which is unique and untransferable.Our current code looks like this:
Here, if the user provides the correct secret, then we should mint a single unit of a Custom Token "ZKTST".
For testing, we're using the following code which is similar to the default
Add.test.ts
test:Unfortunately, this test fails with the following error
Note that we're not creating any new accounts (at least not intentionally), so the sum matches the expected amount (0.00 MINA). We've commented out things we've tried with no success. We've verified that the
senderAccount
has a balance of1000000000000n
MINA throughMina.getBalance(senderAccount).value.toBigInt()
, so being unable to pay fees does not seem to be the reason.