it shouldnāt be this hard to mint an nft
(web3, enableWeb3, isWeb3Enabled} = useMoralis()
your web3 doesnāt expose utils, or .eth so runcontactnative web3 doesnāt workā¦
it shouldnāt be this hard to mint an nft
(web3, enableWeb3, isWeb3Enabled} = useMoralis()
your web3 doesnāt expose utils, or .eth so runcontactnative web3 doesnāt workā¦
The docs provides basic examples required to get basic things done which can be built upon to get complex things done.
Since youāre using react too, react docs explained in similar way ( basic example that can be used to build complex works )
real world examples would be A LOT more helpfulā¦
most devs arenāt going to have a page with one function on it
Real-world examples are showcased in the weekly project series.
Error: Provided address 5.676064741032766e+47 is invalid, the capitalization checksum test failed, or itās an indirect IBAN address which canāt be converted.
What are you trying to do ?
just trying to mint an nftā¦
have tried it this way
const [_mintForm, setMintForm] = useState(null)
useEffect(()=>{
console.log('fetching....')
const mintnftea = async()=> {
{data_, error_ fetch, isFetching} await useWeb3ExecuteFunction({
abi: _nftea,
contractAddress: '0x636c5AC57F13DdAB170d4064F0A3EB3f2949B885',
functionName: "mint",
params: {
secondsAgos: [_mintForm.amount,_mintForm.redeems,_mintForm.metadataurl_.charCodeAt(0),_mintForm.ipfs,_mintForm.payTo,_mintForm.splitwith,_mintForm.split,_mintForm.redeemfrequency],
},
});
}
}, [mintnftea])
form gets submittedā¦ NFTea gets mintedā¦
web3, and every other way from your docsā¦
const JSONdata = JSON.stringify(dataMint_)
const endpoint = '/api/mintnftea'
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSONdata,
}
const response = await fetch(endpoint, options)
const result = await response.json()
sent it to the back end for the evm to do it
export default async function handler(req, res) {
const body = req.body
const functionName = 'mint';
const chain = EvmChain.GOERLI;
const params = {quantity_:body.amount,redeems_:body.redeems,data_:body.metadataurl_.charCodeAt(0),ipfs_:body.ipfs,payto_:body.payTo,splitwith_:body.splitwith,splitpercent_:body.split,redeemfrequency_:body.redeemfrequency};
const address = process.env.NFTEA;
await Moralis.start({
apiKey: process.env.MORALIS_API_KEY,
});
const response = await Moralis.EvmApi.utils.runContractFunction({
functionName,
params,
address,
chain,
});
console.log(response.result);
res.status(200).json({
data: response.result
});
}
doesnāt work and .charCodeAt(0) doesnāt work for the hex converstion
this way
const {data_, error_, fetch, isFetching_} = useWeb3ExecuteFunction({
abi: _nftea,
contractAddress: '0x636c5AC57F13DdAB170d4064F0A3EB3f2949B885',
functionName: "mint",
params: {
secondsAgos: [_mintForm.amount,_mintForm.redeems,_mintForm.metadataurl_.charCodeAt(0),_mintForm.ipfs,_mintForm.payTo,_mintForm.splitwith,_mintForm.split,_mintForm.redeemfrequency],
},
});
then call fetch after the images is uploaded and saved to ipfs
fetch({params:dataMint_})
nothing happensā¦
Regards the first part of the code here, you can get it fixed as Glad mentioned above that hooks should be at the top level.
const { isWeb3Enabled, enableWeb3 } = useMoralis();
const [_mintForm, setMintForm] = useState(null);
const { fetch } = useWeb3ExecuteFunction();
useEffect(() => {
const mintnftea = async () => {
if (!isWeb3Enabled) await enableWeb3();
fetch({
params: {
abi: _nftea,
contractAddress: "0x636c5AC57F13DdAB170d4064F0A3EB3f2949B885",
functionName: "mint",
params: {
secondsAgos: [
_mintForm.amount,
_mintForm.redeems,
_mintForm.metadataurl_.charCodeAt(0),
_mintForm.ipfs,
_mintForm.payTo,
_mintForm.splitwith,
_mintForm.split,
_mintForm.redeemfrequency,
],
},
},
onSuccess: (res) => console.log(res),
onError: (err) => console.log(err),
});
};
mintnftea();
}, []);
You should fix the dependency hook depending on what and when you want it to fire
You can keep track of the process with the logs from onSuccess and onError
As mentioned in the docs, runContractFunction run a given function of a contract abi and retrieve readonly data.
almost got it goingā¦
const {data, error, fetch, isFetching_} = useWeb3ExecuteFunction({
abi: _nftea,
contractAddress: "0x636c5AC57F13DdAB170d4064F0A3EB3f2949B885",
functionName: "mint",
params: {
quantity_: _mintForm.amount,
redeems_: _mintForm.redeems,
data_: _mintForm.metadataurl_.charCodeAt(0),
ipfs_: _mintForm.ipfs,
payto_: _mintForm.payTo,
splitwith_: _mintForm.splitwith,
splitpercent_:_mintForm.redeemfrequency,
redeemfrequency_:_mintForm.split
},
});
invalid address or ENS name (argument=ānameā, value=0, code=INVALID_ARGUMENT, version=contracts/5.6.0)
is there a special way to set addresses in react?
with qoutes, withoutā¦ doesnāt work
Check if the address passed is a valid contract address
You should set it with quotes
invalid address or ENS name (argument=ānameā, value=0, code=INVALID_ARGUMENT, version=contracts/5.6.0)
Try hardcoding the contratc address and see if it works
set it as
export const _contractTea = ā0x636c5AC57F13DdAB170d4064F0A3EB3f2949B885ā;
still getting invalid address or ENS name (argument=ānameā, value=0, code=INVALID_ARGUMENT,
Then you should import it properly where itās required.
all types of bugs on this thing maneā¦
const encodedFunction = new web3.eth.abi.encodeFunctionCall({
gets this error this.encodeFunctionSignature is not a function
tried skipping the fancy stuff and use web3ā¦ still issues
invalid address or ENS name (argument=ānameā, value=0, code=INVALID_ARGUMENT, version=contracts/5.6.0)
Is your walletās chain on Goerli testnet?
const encodedFunction = new web3.eth.abi.encodeFunctionCall({
I agree with you, docs rly very bad . It could be improved!