helios: Transaction Built Successfully But Submit Fails
Thanks for your patience in answering these 😃 This may again be a Lucid interaction in how it is building the tx, but it seems to be having some issue with constructing the Time Translation:
{"code":2,"info":"Wallet could not send the tx.","message":"\"transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (UtxosFailure (CollectErrors [BadTranslation (TimeTranslationPastHorizon \\\"PastHorizon {pastHorizonCallStack = [(\\\\\\\"runQuery\\\\\\\",SrcLoc {srcLocPackage = \\\\\\\"ouroboros-consensus-0.1.0.0-3WJNO431PEsEUwRPtCeeUr\\\\\\\", srcLocModule = \\\\\\\"Ouroboros.Consensus.HardFork.History.Qry\\\\\\\", srcLocFile = \\\\\\\"src/Ouroboros/Consensus/HardFork/History/Qry.hs\\\\\\\", srcLocStartLine = 430, srcLocStartCol = 44, srcLocEndLine = 430, srcLocEndCol = 64}),(\\\\\\\"interpretQuery\\\\\\\",SrcLoc {srcLocPackage = \\\\\\\"ouroboros-consensus-0.1.0.0-3WJNO431PEsEUwRPtCeeUr\\\\\\\", srcLocModule = \\\\\\\"Ouroboros.Consensus.HardFork.History.EpochInfo\\\\\\\", srcLocFile = \\\\\\\"src/Ouroboros/Consensus/HardFork/History/Epoc"}
The behavior is that Nami allows me to sign the tx, but submit returns failure. Here is the Helios contract:
minting voting_ballot
const POLLS_CLOSE: Time = Time::new(1666242000000) // 10/20/22 00:00:00
enum Redeemer {
Mint
}
func main(redeemer: Redeemer, ctx: ScriptContext) -> Bool {
redeemer.switch {
Mint => {
tx: Tx = ctx.tx;
tx_valid: Bool = tx.time_range.is_before(POLLS_CLOSE);
time_range_valid_msg: String = if (tx_valid) { "Valid" } else { "Invalid" };
print(time_range_valid_msg + " time range: " + tx.time_range.serialize().show() + " (polls close at " + POLLS_CLOSE.serialize().show() + ")");
tx_valid
}
}
}
And here is the Javascript code building the txn:
const SINGLE_NFT = 1n;
const POLLS_OPEN = 1664462000000;
const POLLS_CLOSE = 1666242000000;
export async function mintBallot(blockfrostKey, policyID) {
try {
const cardanoDApp = CardanoDAppJs.getCardanoDAppInstance();
validate(cardanoDApp.isWalletConnected(), 'Please connect a wallet before sweeping using "Connect Wallet" button');
const wallet = await cardanoDApp.getConnectedWallet();
const lucid = validated(await LucidInst.getLucidInstance(blockfrostKey), 'Please validate that your wallet is on the correct network');
lucid.selectWallet(wallet);
const voter = await lucid.wallet.address();
// TODO: Get name from the user
const assetName = toHex(new TextEncoder().encode('WildTangz 2'));
const assetId = `${lucid.utils.mintingPolicyToId(MINTING_SCRIPT)}${assetName}`;
const mintAssets = { [assetId]: SINGLE_NFT };
const vendAssets = { lovelace: 2n, [assetId]: SINGLE_NFT };
const txBuilder = lucid.newTx()
.addSigner(voter)
.mintAssets(mintAssets, Data.empty())
.attachMintingPolicy(MINTING_SCRIPT)
.payToAddress(voter, vendAssets)
.validFrom(POLLS_OPEN)
.validTo(POLLS_CLOSE - 1);
const txComplete = await txBuilder.complete();
const txSigned = await txComplete.sign().complete();
const txHash = await txSigned.submit();
shortToast(`Successfully submitted ${txHash}`);
} catch (err) {
shortToast(JSON.stringify(err));
}
}
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 23 (9 by maintainers)
Yes! Worked like a charm when I did
const txComplete = await txBuilder.complete({ nativeUplc: false });
then it compiled fine (which means that this is perhaps an issue in the current version of Aiken? These seem to be the relevant lines for those curious: https://github.com/berry-pool/cardano-multiplatform-lib/blob/vasil/rust/src/tx_builder.rs#L2426-L2445).Defaulting back to Blockfrost works. Closing this issue, thanks.
Alright. Let me try to use your Tx building API in Javascript and get back to you. Can you provide that link in this ticket one more time for myself and others? Thanks for all your help.