Skip to content

SignTransaction with Metamask Snap #300

@Temitope3665

Description

@Temitope3665

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions