Using Truffle to send a transaction to a local TestRPC causes a Buffer is not defined error. The transaction is successfully executed, but the callback causes an error.

Here is my code:

import { View, Text, Button } from 'react-native';
import React, { Component } from 'react';
import styles from './styles';
import { default as Web3} from 'web3';
import { default as contract } from 'truffle-contract'
import metacoin_artifacts from '../../contracts/MetaCoin.json'

const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

var MetaCoin = contract(metacoin_artifacts);


var amount = 10;
var account = '0x8d8a8258daea0fab0309b378b915b2eb7862d5bc';
var receiver = '0x6e6d32a7c1b8c288f2f707c3c2910cb383f3cd83';
var meta;

const sendCoins = () => {
  MetaCoin.deployed().then(function(instance) {
    meta = instance;
    // console.dir(meta);
    return meta.sendCoin(receiver, amount, {from: account});
  }).then(function() {
    console.log('Transaction complete!');
  }).catch(function(e) {

class Ethereum extends Component {
  render() {
    return (
      <View style={styles.container}>
          title="Send coins"
          accessibilityLabel="Learn more about this purple button"

export default Ethereum;

My setup is as follows:

Using Truffle I've compiled and deployed the MetaCoin contracts to a local EthereumJS TestRPC.

I've manually copied the compiled contract files MetaCoin.json, ConvertLib.json and Migrations.json into a React-Native app.

I'm importing both web3 and truffle-contract into a React-Native component.

A screenshot of the full error trace is below:

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.