SignTransaction with Metamask Snap

We implemented connecting wallet with metamask snap, but unfortunately, we’ve been unable to sign a transaction with the metamask snap. i.e interact with the smart contract especially when sending information to the smart contract (e.g. create a dAO or proposal).

Error that we get: “Error: Problem signing transaction: t is undefined”

Code snippet with payload:

const aeSnap = await AESnap.connect(getNetwork());
const signAndSendTransaction = async (payload: TxParamsAsync) => {
return aeSnap?.signAndSendTransaction(payload);
};

const generateKey: any = () => {
const secretKey = CryptoJS.lib.WordArray.random(64).toString();
return secretKey;
};

const account = new MemoryAccount(generateKey());
const newUserAccount = MemoryAccount.generate();
aeSdk.account = account;
aeSdk.accounts = [account, newUserAccount];
const contract = await getBasicDAO(aeSdk, payload.daoContractAddress);

const result = await contract[‘createProposal’](payload.proposalType, payload.description, payload.value, payload.target, payload.info, {
callStatic: true,
onAccount: createOnAccountObject(‘address’),
});
const encodedTx = await result.rawTx;
const response = await signAndSendTransaction({
tag: result.tx.tag,
senderId: result.tx.callerId,
receipientId: result.tx.contractId,
amount: result.tx.fee,
nonce: 1,
payload: encode(new TextEncoder().encode(result), Encoding.Bytearray),
});

Please we need help with the best way to resolve this error and the best way to sign transactions and interact with the smart contract.

2 Likes

Hi Temi!

Driven by the aim of making aengel a really useful tool for the ae community, and specially for devs , I have asked it about your issue … here you have the result, hope that it can help!

If you can’t access the link, just let me know so i can paste the answer here in plain text…

Any feedback or follow up appreciated .

The issue has been resolved.
Thank you for your response.

1 Like

So glad to hear that @Temi ! You can use aengel for tech support, debugging and review anytime you want / need … that’s one of the main purposes it was created for, being an aengel for the ae amazing builders and community. Have a great dæy!!