Here is what I think that you should do (using web3.js v1.2):
const Web3 = require("web3");
// enter your node address and private key below, for example:
const NODE_ADDRESS = "https://mainnet.infura.io/v3/12345678123456781234567812345678";
const PRIVATE_KEY = "0x1234567812345678123456781234567812345678123456781234567812345678";
const USER_WALLET_CONTRACT_ADDR = "0xc653461d3D4c6AD53c16ebE16fa07f820e115139";
const UNI_TOKEN_CONTRACT_ADDR = "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984";
const USER_WALLET_CONTRACT_ABI = [
{
"constant":false,
"inputs":[{"name":"_target","type":"address"},{"name":"_data","type":"bytes"},{"name":"_src","type":"uint256"},{"name":"_session","type":"uint256"}],
"name":"execute",
"outputs":[{"name":"response","type":"bytes"}],
"payable":true,
"stateMutability":"payable",
"type":"function"
}
];
const UNI_TOKEN_CONTRACT_ABI = [
{
"constant":true,
"inputs":[{"internalType":"address","name":"account","type":"address"}],
"name":"balanceOf",
"outputs":[{"internalType":"uint256","name":"","type":"uint256"}],
"payable":false,
"stateMutability":"view",
"type":"function"
},
{
"constant":false,
"inputs":[{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"rawAmount","type":"uint256"}],
"name":"transfer",
"outputs":[{"internalType":"bool","name":"","type":"bool"}],
"payable":false,
"stateMutability":"nonpayable",
"type":"function"
}
];
async function scan(message) {
process.stdout.write(message);
return await new Promise((resolve, reject) => {
process.stdin.resume();
process.stdin.once("data", (data) => {
process.stdin.pause();
resolve(data.toString().trim());
});
});
}
async function getGasPrice(web3) {
while (true) {
const nodeGasPrice = await web3.eth.getGasPrice();
const userGasPrice = await scan(`Enter gas-price or leave empty to use ${nodeGasPrice}: `);
if (/^\d+$/.test(userGasPrice))
return userGasPrice;
if (userGasPrice === "")
return nodeGasPrice;
console.log("Illegal gas-price");
}
}
async function getTransactionReceipt(web3) {
while (true) {
const hash = await scan("Enter transaction-hash or leave empty to retry: ");
if (/^0x([0-9A-Fa-f]{64})$/.test(hash)) {
const receipt = await web3.eth.getTransactionReceipt(hash);
if (receipt)
return receipt;
console.log("Invalid transaction-hash");
}
else if (hash) {
console.log("Illegal transaction-hash");
}
else {
return null;
}
}
}
async function send(web3, account, transaction, value = 0) {
while (true) {
try {
const options = {
data: transaction.encodeABI(),
gas: await transaction.estimateGas({from: account.address, value: value}),
gasPrice: await getGasPrice(web3)
};
const signed = await web3.eth.accounts.signTransaction(options, account.privateKey);
const receipt = await web3.eth.sendSignedTransaction(signed.rawTransaction);
return receipt;
}
catch (error) {
console.log(error.message);
const receipt = await getTransactionReceipt(web3);
if (receipt)
return receipt;
}
}
}
async function run() {
const web3 = new Web3(NODE_ADDRESS);
const account = web3.eth.accounts.privateKeyToAccount(PRIVATE_KEY);
const userWalletContract = new web3.eth.Contract(USER_WALLET_CONTRACT_ABI, USER_WALLET_CONTRACT_ADDR);
const uniTokenContract = new web3.eth.Contract(UNI_TOKEN_CONTRACT_ABI, UNI_TOKEN_CONTRACT_ADDR);
const balance = await uniTokenContract.methods.balanceOf(account.address).call();
const data = uniTokenContract.methods.transfer(account.address, balance).encodeABI();
const transaction = userWalletContract.methods.execute(uniTokenContract._address, data, 0, 0);
const receipt = await send(web3, account, transaction);
console.log(JSON.stringify(receipt, null, 4));
if (web3.currentProvider.disconnect)
web3.currentProvider.disconnect();
}
run();
execute
and pass to it the following parameters:'0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984'
'0xa9059cbb00000000000000000000000034a2860bbba761ae27005799b02d3dbd8b4b5feb000000000000000000000000000000000000000000000015af1d78b58c400000'