Payable UseWeb3ExecuteFunction how to specify value

https://docs.moralis.io/moralis-server/web3/web3#example-of-calling-a-send-contract-method

How do I specify value in a payable function using Moralis?

Here is the source on the function https://github.com/avolabs-io/nft-auction/blob/master/contracts/NFTAuction.sol

const ABI = {
	"inputs": [
		{
			"internalType": "address",
			"name": "_nftContractAddress",
			"type": "address"
		},
		{
		        "internalType": "uint256",
		        "name": "_tokenId",
		        "type": "uint256"
		},
		{
			"internalType": "address",
			"name": "_erc20Token",
			"type": "address"
		},
		{
			"internalType": "uint128",
			"name": "_tokenAmount",
			"type": "uint128"
		}
	],
	"name": "makeBid",
        "outputs": [],
	"stateMutability": "payable",
	"type": "function"
}

const options = {
      chain: "polygon",
      contractAddress: AUCTION_CONTRACT_ADDRESS,
      functionName: "makeBid",
      abi: ABI,
      params: {
        _nftContractAddress: TOKEN_CONTRACT_ADDRESS,
        _erc20Token: ZERO_ADDRESS (TO Specifiy the native MATIC token with this contract),
        _tokenId: _tokenId,
        _tokenAmount: ZERO, only applicable to ERC20s,
        
        Do I add an additional param such as value, in wei?
        value: 10000 

      },
};

https://docs.moralis.io/moralis-server/web3/web3#executefunction

msgValue(optional): Number|String|BN|BigNumber. The value transferred for the transaction in wei.

const options = {
      chain: "polygon",
      contractAddress: AUCTION_CONTRACT_ADDRESS,
      functionName: "makeBid",
      abi: ABI,

      // Like so?
      msgValue(10000),

      params: {
        _nftContractAddress: TOKEN_CONTRACT_ADDRESS,
        _erc20Token: ZERO_ADDRESS (TO Specifiy the native MATIC token with this contract),
        _tokenId: _tokenId,
        _tokenAmount: ZERO, only applicable to ERC20s,
      },
};

I think that it is msgValue: 1000000000

const options = {
      chain: "polygon",
      contractAddress: AUCTION_CONTRACT_ADDRESS,
      functionName: "makeBid",
      abi: ABI,
      msgValue: Moralis.Units.ETH("0.1"),
      params: {
        _nftContractAddress: TOKEN_CONTRACT_ADDRESS,
        _erc20Token: ZERO_ADDRESS (TO Specifiy the native MATIC token with this contract),
        _tokenId: _tokenId,
        _tokenAmount: ZERO, only applicable to ERC20s,
      },
};
1 Like

The <3 is real.

Launch tomorrow!

1 Like