Repository navigation
Is there any way to integrate the current protocol-kit with viem.sh?, I only see ethers-web3 adapters #474
Unanswered
Guillermo (guillermoriv)
asked this question in
Q&A
Replies: 2 comments 1 reply
|
Guillermo (@guillermoriv) I found a way in wagmi documentation to get the "Signer" (ethers) when you have a "WalletClient" (viem). With the Signer you can create the adapter. https://wagmi.sh/core/ethers-adapters#wallet-client--signer I know this is not a solution, because you should install ethers, but I think could be a way to handle this moment of migrations from ethers to viem |
1 reply
|
I've started developing a Safe library for viem. Example usage for transaction proposal: import { http, createPublicClient, parseEther, createWalletClient, Hex } from 'viem'
import { goerli } from 'viem/chains'
import { publicSafeActions, walletSafeActions } from '@stauro/piggybank/actions'
import { EIP3770Address, OperationType } from '@stauro/piggybank/types'
import { ApiClient } from '@stauro/piggybank/api'
import { privateKeyToAccount } from 'viem/accounts'
const safeAddress = process.env.SAFE_ADDRESS as EIP3770Address
const publicClient = createPublicClient({
transport: http(),
chain: goerli,
}).extend(publicSafeActions(safeAddress))
const walletClient = createWalletClient({
transport: http(),
chain: goerli,
account: privateKeyToAccount(process.env.PK as Hex),
}).extend(walletSafeActions(safeAddress))
const txData = {
to: process.env.SAFE_TO as EIP3770Address,
value: parseEther('0.001'),
operation: OperationType.Call,
gasPrice: await publicClient.getGasPrice(),
}
const safeTxGas = await publicClient.estimateSafeTransactionGas(txData)
const baseGas = await publicClient.estimateSafeTransactionBaseGas({ ...txData, safeTxGas })
const nonce = await publicClient.getSafeNonce()
const safeTxHash = await publicClient.getSafeTransactionHash({ ...txData, safeTxGas, baseGas, nonce })
const senderSignature = await walletClient.generateSafeTransactionSignature({ ...txData, nonce, safeTxGas, baseGas })
const apiClient = new ApiClient({ url: 'https://safe-transaction-goerli.safe.global', safeAddress })
await apiClient.proposeTransaction({
safeTransactionData: { ...txData, safeTxGas, baseGas, nonce },
senderAddress: walletClient.account.address,
safeTxHash,
senderSignature,
chainId: goerli.id,
origin: 'Piggybank',
nonce,
}) |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I was just wondering if somehow I could create an adapter or if this is something that you guys are planning to do under viem.sh
All reactions