You say that it worked fine before 4-5 hours ago?
Yesā¦
now i update the old server 0.0.260 to new for check the error⦠and get the same error on web3 call in cloud function (
This code works fine in particular for me:
Moralis.Cloud.define("test_web3", async (request) => {
const web3 = Moralis.web3ByChain('0x38')
const abi = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}]
address = "0x2170Ed0880ac9A755fd29B2688956BD959F933F8"
const contract = new web3.eth.Contract(abi, address)
const name = await contract.methods
.name()
.call()
.catch((e) => logger.error(`callName: ${e}${JSON.stringify(e, null, 2)}`))
return name;
});
But with some variations on the address will not work any more.
i get for all request(
if you try from another server, you get same error?
after update the server get the same
I mean for a totally different server, if you run that cloud function if it works
it works before well ⦠i donāt touch any thingā¦
later check that donāt have some datasā¦
come to check the server and see - the server updated and make errorsā¦
)
i check other dev server with same function and there all was fine. all work correct.
I upgrade the server there for check. and the function get the same error⦠after that )
const ContractCall = async (abi, address) => {
try {
const web3 = Moralis.web3ByChain('0x38')
const contract = new web3.eth.Contract(abi, address)
const name = await contract.methods
.name()
.call()
.catch((e) => logger.error(`callName: ${JSON.stringify(e, null, 2)}`))
const symbol = await contract.methods
.symbol()
.call()
.catch((e) => logger.error(`callSymbol: ${JSON.stringify(e, null, 2)}`))
const totalSupply = await contract.methods
.totalSupply()
.call()
.catch((e) =>
logger.error(`call_TotalSupply: ${JSON.stringify(e, null, 2)}`)
)
const decimals = await contract.methods
.decimals()
.call()
.catch((e) =>
logger.error(`call_decimals: ${JSON.stringify(e, null, 2)}`)
)
return { name, symbol, totalSupply, decimals }
} catch (e) {
logger.error(`web3ERORr: ${e} ${JSON.stringify(e, null, 2)}`)
return null
}
}
here the full code of function
the problem come on 24 Sept 2021 at 09:15:49 UTC
but it can just upgrade the server at that time.
Iām surprised why it upgrade automatically.
maybe I can downgrade it in some way?
https://z86sr8zvw8qz.moralisweb3.com:2053/server
here is the server, if it helps )
Just to remove other possible problems, if you add this cloud function and run it you get same error?
Moralis.Cloud.define("test_web3", async (request) => {
const web3 = Moralis.web3ByChain('0x38')
const abi = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}]
address = "0x2170Ed0880ac9A755fd29B2688956BD959F933F8"
const contract = new web3.eth.Contract(abi, address)
const name = await contract.methods
.name()
.call()
.catch((e) => logger.error(`callName: ${e}${JSON.stringify(e, null, 2)}`))
return name;
});
same
callName_test_web3: Error: Invalid JSON RPC response: āUnauthorizedā{}
It looks like it doesnāt work on latest server version, it will get fixed. I tested on an older server version.
do you know some way to downgrade version?
Im 1 am nowā¦
I will glad to fix that and go to push(pillow)
Work around:
Moralis.Cloud.define("test_web32", async (request) => {
web3 = new Moralis.Web3(new Moralis.Web3.providers.HttpProvider("https://speedy-nodes-nyc.moralis.io/YOUR_ID_HERE/bsc/mainnet"));
const abi = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}]
address = "0x2170Ed0880ac9A755fd29B2688956BD959F933F8"
const contract = new web3.eth.Contract(abi, address)
const name = await contract.methods
.name()
.call()
.catch((e) => logger.error(`callName: ${e}${JSON.stringify(e, null, 2)}`))
return name;
});
Hey @DmKodOff
The problem was fixed. I tested this function on your server - it worked correctly.
Let me know how it works for you now
Thank You. All was worked good after fix.
Happy BUIDLing