diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/contract_wrappers/token_wrapper.ts | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts index 6cb71c7e8..55e1e364b 100644 --- a/src/contract_wrappers/token_wrapper.ts +++ b/src/contract_wrappers/token_wrapper.ts @@ -102,6 +102,12 @@ export class TokenWrapper extends ContractWrapper { assert.isBigNumber('amountInBaseUnits', amountInBaseUnits); const tokenContract = await this.getTokenContractAsync(tokenAddress); + + const fromAddressBalance = await this.getBalanceAsync(tokenAddress, fromAddress); + if (fromAddressBalance.lessThan(amountInBaseUnits)) { + throw new Error(ZeroExError.INSUFFICIENT_BALANCE_FOR_TRANSFER); + } + await tokenContract.transfer(toAddress, amountInBaseUnits, { from: fromAddress, }); |