Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sending token via Ethereum smart contract interaction with redux-saga
// full source:
export function* SendTransaction() {
try {
// ...
const contractAddress = tokenInfo.contractAddress;
const sendParams = { from: fromAddress, value: '0x0', gasPrice, gas: maxGasForTokenSend };
const tokenAmount = amount * (10 ** tokenInfo.decimals);
function sendTokenPromise(tokenContractAddress, sendToAddress, sendAmount, params) {
return new Promise((resolve, reject) => {
const tokenContract =;
tokenContract.transfer.sendTransaction(sendToAddress, sendAmount, params, (err, sendTx) => {
if (err) return reject(err);
return resolve(sendTx);
const tx = yield call(sendTokenPromise, contractAddress, toAddress, tokenAmount, sendParams);
// This saga will resume running after the transaction is sent and tx is returned by Ethereum node
// ...
yield put(sendTransactionSuccess(tx));
} catch (err) {
// ...
yield put(sendTransactionError(errMsg));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.