Created
January 6, 2022 01:15
-
-
Save webmodularity/640bb086a466ab827c51366d59964abe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { default: EthersSafe, EthersAdapter } = require("@gnosis.pm/safe-core-sdk"); | |
const ethers = require("ethers"); | |
//require('dotenv').config({ path: `${__dirname}/../../.env` }) | |
const SafeDisperseContract = require("./artifacts/SafeDisperse.json"); | |
const ERC20Contract = require("./artifacts/ERC20.json"); | |
const safeDisperseInterface = new ethers.utils.Interface(SafeDisperseContract.abi); | |
const erc20Interface = new ethers.utils.Interface(ERC20Contract.abi); | |
// Address constants | |
const safeAddress = "0x7328285B4435dbc51897DC2d900D21707d14253e"; | |
const BATERC20Rinkeby = "0xbF7A7169562078c96f0eC1A8aFD6aE50f12e5A99"; | |
const zrxERC20Rinkeby = "0xddea378A6dDC8AfeC82C36E9b0078826bf9e68B6"; | |
const recipient1 = "0x6c25c43856df0fcb79b151c9c2f9a9dcc2eb46be"; | |
//const safeDisperseRinkebyAddress = "0xD241025F2a4f958Cd6CA0Ac1b85F66859F71c4a2"; | |
// Hradcoded this for simplicity | |
const chainId = 4; | |
const contractNetworks = { | |
[chainId]: { | |
multiSendAddress: "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", | |
safeMasterCopyAddress: "0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552", | |
safeProxyFactoryAddress: "0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2" | |
} | |
} | |
async function main() { | |
const provider = ethers.getDefaultProvider(process.env.INFURA_RINKEBY_URL); | |
const signer = new ethers.Wallet(process.env.PRIVATE_KEY, provider); | |
const ethAdapter = new EthersAdapter({ ethers, signer }); | |
const safeSdk = await EthersSafe.create({ | |
ethAdapter: ethAdapter, | |
safeAddress: safeAddress, | |
contractNetworks | |
}); | |
// Create Transaction | |
const multiSendTx = [ | |
{ | |
to: zrxERC20Rinkeby, | |
data: erc20Interface.encodeFunctionData("transfer", [ | |
recipient1, | |
ethers.BigNumber.from(10).pow(18).mul(1), | |
]), | |
value: "0", | |
}, | |
{ | |
to: BATERC20Rinkeby, | |
data: erc20Interface.encodeFunctionData("transfer", [ | |
recipient1, | |
ethers.BigNumber.from(10).pow(18).mul(1), | |
]), | |
value: "0", | |
} | |
]; | |
const txOptions = { | |
safeTxGas: 2300, | |
baseGas: 112000, | |
refundReceiver: signer.address, | |
gasPrice: 3500000000 | |
//gasPrice: 2500000000, | |
//gasToken: "0x0000000000000000000000000000000000000000" | |
}; | |
const safeTransaction = await safeSdk.createTransaction(multiSendTx, txOptions); | |
console.log(safeTransaction); | |
// Execute Transaction | |
const execOptions = { | |
gasLimit: 350000 | |
}; | |
//const executeTxResponse = await safeSdk.executeTransaction(safeTransaction, execOptions); | |
//const receipt = await executeTxResponse.transactionResponse?.wait(); | |
//console.log(receipt.transactionHash); | |
} | |
main() | |
.then(() => process.exit(0)) | |
.catch((error) => { | |
console.error(error); | |
process.exit(1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment