Deploy contract using safe wallet #523
Replies: 3 comments 9 replies
-
Yes, while your Safe Account itself is not an Externally Owned Account (EOA) and therefore cannot natively deploy a smart contract directly like an EOA would, it's still possible to deploy new contracts using your Safe. To accomplish this, you would need to interact with a contract that is designed to create other contracts. We have a To interact with the Within the Transaction Builder, you can input both the contract details and the specific function parameters you aim to call. This enables you to invoke the performCreate function on the CreateCall contract: On the Goerli network, the address for the CreateCall contract is First, , input the CreateCall contract address: Then, select the desired method for creating your contract ( Now you can click on For reference, you can view this transaction with this example here. I deployed this smart contract using my Safe Account in this transaction Note: if you check the owner of the test contract that I deployed using my Safe Account you can see that the owner is the This arises because I executed a call from my Safe Account to the Thanks! |
Beta Was this translation helpful? Give feedback.
-
If you need to deploy via delegateCall, you can utilize our protocol-kit: import Safe, { EthersAdapter, getCreateCallContract } from '@safe-global/protocol-kit'
import { OperationType } from '@safe-global/safe-core-sdk-types'
import { ethers } from 'ethers'
// Goerli config
const config = {
RPC_URL: 'https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161',
SAFE_SIGNER_PRIVATE_KEY: '<SIGNER_PK>',
SAFE_ADDRESS: '<YOUR_SAFE_ADDRESS>' // Goerli Safe 1/1
}
const contractBytecode =
'0x6080604052348015600f57600080fd5b50600080546001600160a01b0319163317905560a0806100306000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063893d20e814602d575b600080fd5b60336047565b604051603e91906056565b60405180910390f35b6000546001600160a01b031690565b6001600160a01b039190911681526020019056fea2646970667358221220898723a0669d8eb946185c275f6547a97576c55c9bcee1bae7035f9d6bd2f44364736f6c63430008000033'
// Safe version
const safeVersion = '1.3.0'
async function main() {
console.log(`Deployment of a contract from a Safe Account:`)
// SDK Initialization
const provider = new ethers.providers.JsonRpcProvider(config.RPC_URL)
const signer = new ethers.Wallet(config.SAFE_SIGNER_PRIVATE_KEY, provider)
const ethAdapter = new EthersAdapter({
ethers,
signerOrProvider: signer
})
const safeSDK: Safe = await Safe.create({
ethAdapter,
safeAddress: config.SAFE_ADDRESS
})
// Here we add the deployment of the contract with my Safe Account
const createCallContract = await getCreateCallContract({ ethAdapter, safeVersion })
const createCallContractAddress = await createCallContract.getAddress()
const value = '0'
const data = createCallContract.encode('performCreate', [value, contractBytecode])
// transaction with the deployment (it is a delegateCall from the Safe Account to the performCreate method of the createCall contract)
const transaction = {
to: createCallContractAddress,
value,
data,
operation: OperationType.DelegateCall
}
const safeTransaction = await safeSDK.createTransaction({ safeTransactionData: transaction })
// we execute the deployment contract transaction
const { transactionResponse } = await safeSDK.executeTransaction(safeTransaction)
const receipt = await transactionResponse?.wait()
console.log('Transaction executed:')
console.log(`https://goerli.etherscan.io/tx/${receipt.transactionHash}`)
}
main() You can check the transaction details here You can see that when deploying via delegateCall, the owner of the contract becomes the Safe Contract itself, rather than the Let me know if you need more help or have any other questions! |
Beta Was this translation helpful? Give feedback.
-
But when i deploy a contract using transaction builder i got error "Failed. Execution reverted: GS013." In performCreate i passed value as a zero & passed bytecode of the contract. |
Beta Was this translation helpful? Give feedback.
-
I created a safe wallet on goerli testnet. Can we deploy new smart contract using safe wallet?
Beta Was this translation helpful? Give feedback.
All reactions