cosmos / cosmjs

The Swiss Army knife to power JavaScript based client solutions ranging from Web apps/explorers over browser extensions to server-side clients like faucets/scrapers.
https://cosmos.github.io/cosmjs/
Apache License 2.0
645 stars 330 forks source link

"Invalid funds" issue #1463

Closed player1122ez closed 9 months ago

player1122ez commented 1 year ago

(i couldnt find the place where i can post my issue, so i do here) When i try to execute contract function "mint_native" using prebuilt code snippet on sei testnet(seiscan app explorer), i get "invalid funds" error. Im not really into cosmos ecosystem, but im pretty sure its related to "attached funds" section in transaction details page. image

my addr: sei1pds9v27aavj56ldy04jp8m22wwjvkkf9s9tnh6 Succeded tx example(Executed on mintpage using keplr wallet) : 5987DD311CA5A0D1458C8091D6999F7B2B2DF72B1A7F4E5248AA0A2A322AA2F5 (hash) Failed tx example : 0C05C265D3794C617B905F90AE92FFC2C26E8007C95281DFD8C4977049D6169F (hash) tx details can be found in "seiscan app"

Error message: "Query failed with (6): rpc error: code = Unknown desc = failed to execute message; message index: 0: Invalid Funds: execute wasm contract failed [sei-protocol/sei-wasmd@v0.0.2/x/wasm/keeper/keeper.go:364] With gas wanted: '10000000' and gas used: '130019' : unknown request"

code snippet i used:

const { GasPrice } = require("@cosmjs/stargate");
const { SigningCosmWasmClient } = require("@cosmjs/cosmwasm-stargate");
const { getOfflineSignerAmino } = require("cosmjs-utils");
const { chains } = require("chain-registry");

// TODO: Replace with your mnemonic (not recommended for production use)
const mnemonic =
  "<MNEMONIC>";
const chain = chains.find(({ chain_name }) => chain_name === 'seitestnet2');
const contractAddress =
  'sei1355u0d5np4aphkysqvlr6ca43gcdlqn2cmxysw24lrjz0zxjrufsfp6vhp';

const execute = async () => {
  const rpcEndpoint = 'https://rpc.atlantic-2.seinetwork.io';
  const signer = await getOfflineSignerAmino({ mnemonic, chain });
  const client = await SigningCosmWasmClient.connectWithSigner(
    rpcEndpoint,
    signer,
    {
      gasPrice: GasPrice.fromString("0.025usei"),
    }
  );

  const [sender] = await signer.getAccounts();
  const fee = "auto";

  const tx = await client.execute(
    sender.address,
    contractAddress,
    {
  "mint_native": {
    "collection": "sei1ce9ae3et2aqajaklh4ethmmw25e449hhtnx7ghnxquxxkudekq0se54e0n",
    "group": "Public",
    "recipient": "sei1pds9v27aavj56ldy04jp8m22wwjvkkf9s9tnh6",
    "merkle_proof": null,
    "hashed_address": null
  }
},
    fee
  );

  console.log(tx.transactionHash);
};

execute();
;

image

webmaster128 commented 10 months ago

I'm not completely sure, but this can also be an error during the contract execution. Can you share the code of the contract you execute?

webmaster128 commented 9 months ago

I guess this is a contract error. Closing for now. Feel free to re-open if you have more info.