I followed the steps on the answer for Deploying contracts from safe wallet and I'm able to use protocol-kit
to create, sign and execute transactions. This will work if I want to perform signing using these scripts.
However, I can't broadcast these transactions to the other wallets so they can sign this from the UI.
I believe we have to use the ApiKit for this. Here's what I'm using as script
const apiKit = new SafeApiKit({
chainId: 47646289n,
txServiceUrl: "http://localhost:8000/txs/api", // http:localhost:8000/txs don't work
});
const txData = createDeployContractTransaction(BYTECODE, 0n);
const tx = await protocolKitOwner.createTransaction({
transactions: [
{
to: CREATECALL_CONTRACT_ADDRESS,
data: txData,
value: 0n,
operation: 1,
},
],
});
const txHash = await protocolKitOwner.getTransactionHash(tx);
const txResponse = await protocolKitOwner.approveTransactionHash(txHash);
const safeTxHash = await protocolKitOwner.getTransactionHash(
tx
);
const signature = await protocolKitOwner.signHash(safeTxHash);
await apiKit.proposeTransaction({
safeAddress: SAFE_ADDRESS,
safeTransactionData: txData, // Contract creation byte code for the contract to deploy
safeTxHash,
senderSignature: signature.data,
senderAddress: SIGNER_ADDRESS
});
// await protocolKitOwner.signTransaction({transaction: tx})
// await protocolKitOwner.executeTransaction(tx) // Successfully executes if Safe has a single owner
The errors I get on proposeTransaction
line are
Error: Unprocessable Entity
at sendRequest (/Users/arpitkarnatak/Desktop/personal/node-pg/node_modules/@safe-global/api-kit/dist/src/utils/httpRequests.js:56:11)