Hello,
I have this code from the documentation about calling a function from the cloud. How to change it such that I can sign a transaction with my private key and write it to the contract on the cloud?
letβs say my private key is = XXXXXXXXXX;
Moralis.Cloud.define("run_contract_function_with_web3", async (request) => {
web3 = new Moralis.Web3(
new Moralis.Web3.providers.HttpProvider(
"RPC URL"
)
);
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;
});
Iβm stuck with this for days. Please help me.
Thank you.