Use signature request from cloud function?

Hello,

My goal is to use Metamask as an alert system, to show that something relating to the contract has changed. Similar to how Moralis login requests a signature (except I have no need to verify that the request gets signed)

I have set up a cloud function with following code. I do not get an error, but I do not get a metamask alert either…

const web3 = Moralis.web3ByChain(‘0x89’)
const myContract = new web3.eth.Contract(ABI, contractAddress)
const owners = await myContract.methods.getOwners().call();

web3.eth.sign(“Message for owners”, “//This is a hardcoded address for the moment”);

return owners;

This code runs and returns owners, but web3.eth.sign() is either failing or not being called or not showing up on the wallet end.

THANKS!!!

I also tried web3.eth.personal.sign(message, address) with the same results.

who has to sign this message in cloud code? you hardcoded a private key somewhere?

the getOwners() function returns addresses. Eventually I will try to parse that list and send messages to specific addresses from that function call. For now I hardcoded my address into there, I removed the address for this post

The real code uses an address like this FAKE one “0x45AB16f4b3Ac1789ghD0f453457eE8Da7780d3d8”

You will need a private key if you want to sign something in cloud code.

Sorry if I was confusing. I don’t want to sign anything in the cloud, I want to initiate a metamask signature popup from the cloud.

This works with JS on the client side, but not from the cloud function.
const web3 = new Web3(window.ethereum);
web3.eth.sign(web3.utils.sha3(‘Message’),‘0xXXXXXXXxxxxxxxxxxxxxxxxxxxXXXxxxxxx’);

I am assuming it is some type of safety issue with Metamask being active and connected. So far I don’t think this is going to work.

Cloud code runs on a server, not in front end. You can not start a MetaMask pop up like that.

Thanks, I think i misunderstood how the metamask alerts worked.