Giter Site home page Giter Site logo

token_sale's People

Contributors

gwmccubbin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

token_sale's Issues

issue with new syntax

as syntax has changed
there is issue running the code
i was able to run it after doing some changes but was not able to properly run the code
front end is loading but not working properly

will feel great if someone can link to his/her repository whose code is working properly

end

how do you end sale?

TokenSale doesn't pay the tokens to the buyer.

I'm testing the tokensale contract in remix and I think this line isn't working as expected.

require(tokenContract.transfer(msg.sender, _numberOfTokens));

Its returns false, because it doesn't complete the transfer. For the same reason

tokensSold += _numberOfTokens

doesn't execute.

I saw all the test you did in truffle, but I'm not really sure if this case was completed. In that case Remix could be the problem.

Regards.

How to fix “No events were emitted”

I have been following the instructions in the Dapp university tutorial. But I am using Windows 10, Dapp University is Mac.

I downloaded this truffle with smart contract ERC20 from Dapp university.
Reference: https://github.com/dappuniversity/token_sale

This is the reference of the solidity (I only rename the file to bruce.sol) https://github.com/dappuniversity/token_sale/blob/master/contracts/DappToken.sol

Where I run truffle test --network development this displays:

Using network 'local'.

  Contract: BruceToken
    √ initializes the contract with the correct values
    √ allocates the initial supply upon deployment
    1) transfers token ownership
    > No events were emitted
    2) approves tokens for delegated transfer
    > No events were emitted
    3) handles delegated token transfers
    > No events were emitted

  Contract: BruceTokenSale
    √ initializes the contract with the correct values
    4) facilitates token buying

    Events emitted during test:
    ---------------------------

    Transfer(_from: <indexed>, _to: <indexed>, _value: 750000)

    ---------------------------
    5) ends token sale
    > No events were emitted


  3 passing (32s)
  5 failing

  1) Contract: BruceToken
       transfers token ownership:
     AssertionError: error message must contain revert
      at test\BruceToken.js:39:7
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

  2) Contract: BruceToken
       approves tokens for delegated transfer:
     TypeError: Cannot read property 'call' of undefined
      at test\BruceToken.js:62:36
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

  3) Contract: BruceToken
       handles delegated token transfers:
     AssertionError: cannot transfer value larger than approved amount
      at test\BruceToken.js:97:7
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

  4) Contract: BruceTokenSale
       facilitates token buying:
     AssertionError: cannot purchase more tokens than available
      at test\BruceTokenSale.js:61:7
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

  5) Contract: BruceTokenSale
       ends token sale:

      returns all unsold bruce tokens to admin
      + expected - actual

      -250000
      +999990

      at test\BruceTokenSale.js:82:14
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)



PS D:\Blvnp\DappUniversity\brucev2token_sale-master>
PS D:\Blvnp\DappUniversity\brucev2token_sale-master>
PS D:\Blvnp\DappUniversity\brucev2token_sale-master>
PS D:\Blvnp\DappUniversity\brucev2token_sale-master>
PS D:\Blvnp\DappUniversity\brucev2token_sale-master> ^C
PS D:\Blvnp\DappUniversity\brucev2token_sale-master> truffle test --network development
Could not connect to your Ethereum client. Please check that your Ethereum client:
    - is running
    - is accepting RPC connections (i.e., "--rpc" option is used in geth)
    - is accessible over the network
    - is properly configured in your Truffle configuration file (truffle.js)

PS D:\Blvnp\DappUniversity\brucev2token_sale-master> truffle test --network development
Using network 'development'.



  Contract: BruceToken
    √ initializes the contract with the correct values (165ms)
    √ allocates the initial supply upon deployment (44ms)
    √ transfers token ownership (214ms)
    1) approves tokens for delegated transfer
    > No events were emitted
    2) handles delegated token transfers

    Events emitted during test:
    ---------------------------

    Transfer(_from: <indexed>, _to: <indexed>, _value: 100)

    ---------------------------

  Contract: BruceTokenSale
    √ initializes the contract with the correct values (41ms)
    √ facilitates token buying (401ms)
    √ ends token sale (501ms)


  6 passing (2s)
  2 failing

  1) Contract: BruceToken
       approves tokens for delegated transfer:
     TypeError: Cannot read property 'call' of undefined
      at test\BruceToken.js:62:36
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

  2) Contract: BruceToken
       handles delegated token transfers:
     AssertionError: cannot transfer value larger than approved amount
      at test\BruceToken.js:97:7
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

Now this is my truffle.js:

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "*"
    },
    local: {
      host: "192.168.*.***",
      port: 1201,
      gas: 2000000,
      gasPrice: 10000000000,
      network_id: "*"
    }
  }
};

problem with new syntax

there are couple of problems
first: version of pragma should change to pragma solidity >=0.4.0 <0.6.0;
second : using same name for constructor function as contract name is deprecated
third : this keyword always raise a error in tokensale.sol I'm not sure why
by the way thanks for great videos

Contract interaction transaction: Metamask RPC Error

I am running project on ganache. when i try to buy tokens by sending transaction via metamask- transaction fails by giving following errors:

inpage.js:1 MetaMask - RPC Error: Error: [ethjs-rpc] rpc error with payload {"id":411318744490,"jsonrpc":"2.0","params":["0xf892018501dcd650008307a12094f9a46958e0fb6575f06713f711b39684d23a92ae87038d7ea4c68000a43610724e0000000000000000000000000000000000000000000000000000000000000001822d46a048e440266148abb2b4a1bee91e6854683f5228451791d9314b0a09f816aaece5a003c233087a5cfc720acf0c363da1c76850dcf77dbcce1aec527e8e850afc6b5c"],"method":"eth_sendRawTransaction"} [object Object] 
{code: -32603, message: "Error: [ethjs-rpc] rpc error with payload 
{"id":41…method":"eth_sendRawTransaction"} [object Object]",
 stack: "Error: Error: [ethjs-rpc] rpc error with payload {…method":"eth_sendRawTransaction"} [object Object]"}
(index):1 Uncaught (in promise) {code: -32603, message: "Error: [ethjs-rpc] rpc error with payload {"id":41…method":"eth_sendRawTransaction"} [object Object]", stack: "Error: Error: [ethjs-rpc] rpc error with payload {…method":"eth_sendRawTransaction"} [object Object]"}
Promise.then (async)
buyTokens @ app.js:123
onsubmit @ (index):31

Error not being triggered when transferFrom is greater than balance

This is the part that is not getting triggered in the test.

// try transferring more then senders balance
             return tokenInstance.transferFrom(fromAccount, toAccount, 9999, {from: spendingAccount});
         }).then(assert.fail).catch(function(error){
            assert(error.message.indexOf('revert') >= 0, 'cannot transfer value larger than balance');

When I run the test I get no error.

I am using solidity 0.5.0 and I am following the update from the pull request. It should give me an error.
Truffle v5.0.2 (core: 5.0.2)
Solidity v0.5.0 (solc-js)
Node v12.16.3

You can see all my code here;
https://github.com/Madeindreams/AGC

I have updated truffle;

Truffle v5.1.43 (core: 5.1.43)
Solidity v0.5.16 (solc-js)
Node v12.16.3
Web3.js v1.2.1

By running the test with the --debug flag I can see the transactions

agcToken.Transfer(
     _from: <indexed> 0x75e627FA8fc6435685D2A2Bc0AD7f0CfF2837256 (type: address),
     _to: <indexed> 0xe736ff01F65bfe3e27e30583bA884F608b76c680 (type: address),
     _value: 100 (type: uint256)
   )

   agcToken.Approval(
     _owner: <indexed> 0xe736ff01F65bfe3e27e30583bA884F608b76c680 (type: address),
     _spender: <indexed> 0x12E4874F55F7f5705Cfaa6E7aA2d831Fd434fbC8 (type: address),
     _value: 10 (type: uint256)
   )

   agcToken.Transfer(
     _from: <indexed> 0xe736ff01F65bfe3e27e30583bA884F608b76c680 (type: address),
     _to: <indexed> 0x3c233d00E365E960E3411AFDd8b61a02e274beAc (type: address),
     _value: 999999999999999 (type: uint256)
   )

This shouldn't work since I dont have that much token?

Also, Visual studio is giving me a warning for the transferFrom function;

function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
}

Function state mutability can be restricted to pure.

Even if I add pure or view. It still doesn't throw an error.

allowance should be accumulate in function approve

hi,

function approve(address _spender, uint256 _value) public returns (bool success) {

    allowance[msg.sender][_spender] = _value;

    Approval(msg.sender, _spender, _value);

    return true;

}

should be change to (due to one msg.sender could approve for same _spender many time)

function approve(address _spender, uint256 _value) public returns (bool success) {

    allowance[msg.sender][_spender] += _value;

    Approval(msg.sender, _spender, _value);

    return true;

}

Uncaught ReferenceError when buyTokens

When calling buyTokens function i get error:

Uncaught ReferenceError: then is not defined at Object.BuyTokens at HTMLButtonELement.onsubmit

My index.html file is exact as in tutorial.

I have no idea how to resolve it. Besides whole code is a bit outdated and required modifying it a lot this one is beyond my skills, help would be highly appreciated.

returns all unsold dapp tokens to admin

on the new patch of Ganace 1.3.0 constantinople a new error showed

returns all unsold dapp tokens to admin
+ expected - actual

  -1000000
  +999990

assert.equal(balance.toNumber(), 999990, 'returns all unsold dapp tokens to admin');

Missing From Videos

  1. How to get an instance which will permit the call of endSale()?
  2. How to get the Ether from the sale contract?

VM Exception: Blank Address + Cannot Purchase More Tokens Than Available

Hey everyone. I was testing my UI and I got an offshoot of the posted "VM exception while processing transaction revert" error, but detailing a purchase of more tokens than available

Refer to the four screenshots below. The first is the default loading page. I will initially purchase 1 DAPP token.
image
image

Upon stepping through the transaction, it then gets rejected due to overstepping a balance
image

As you can see from my DappToken.sol file, I have a circulating supply of 75000 tokens.. how could I possibly overstep the balance? I then reasoned its not the circulating supply- it's one of the functions. Is my reasoning on the right track?
image

From my DappTokenSale.sol file, I have isolated the function triggering this error message
image

When going into truffle console and investigating possible errors, I noticed the tokenSale address is undefined.. why? As per the second screenshot, I was able to link the Ganache test account to Metamask, which is automatically preloaded with 100 fake ETH.. how could I have an undefined address?
image

Forgive me, as I am a novice programmer and am still learning. Please point me in the right direction

hello i need help please error on selfdestruct(admin);

 Error: Attempting to run transaction which calls a contract function, but recipient address 0x50ff3bf83d309adad1bf04cc584d27dfd94d2917 is not a contract address
  at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/errors.js:38:1)
  at /usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:86:1
  at /usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-provider/wrapper.js:134:1
  at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/httpprovider.js:128:1)
  at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:64:1)
  at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:354:1)
  at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:509:1)
  at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:469:1)
  at endReadableNT (_stream_readable.js:1094:12)
  at process._tickCallback (internal/process/next_tick.js:63:19)

GetAccounts (Capstone Project Pt. 2-UI Setup)

Hi Hoping to get some eyes on this. Trying to get through the Capstone project and for some reason my array of accounts is coming up blank [] in the console:

import React, { Component } from 'react';
import './App.css';
import Web3 from 'web3'

class App extends Component {
    componentWillMount() {
      this.loadBlockchainData()
    }

    async loadBlockchainData() {
      const web3 = new Web3(Web3.givenProvider || 'http://localhost:7545')
      const network = await web3.eth.net.getNetworkType()
      const accounts = await web3.eth.getAccounts()
      console.log('accounts', accounts)
    }

Balance of token sale contract

Hi,

In the smart contract tests we commission 75% of the tokens to the sale smart contract. however this is not done when we deploy contracts to use fo the front-end. This gives an error as when I try to buy some tokens, the balance of the contract instantiating the transfer function is empty. Can you please point me to what I am missing?

Thanks :)

#14 episode- Balance on the Rinkeby but no when using comand bash

I can't understand if i'm really connected on the rinkeby teste net...

Here when a use de command "geth --rinkeby --rpc --rpcapi="personal,eth,network,web3,net"

without the params { --ipcpath "\geth.ipc" } or with

Obs.: i don't understand the --ipcpath on the windows and not find some cleary material on the google forums.

Here where i check that i have founds on the account { 0xE78b6BA16B46892c312C5957a333CD948B11d7BC }
image

image

Now, deploying againg the project with truffle, afterward unlock the account i have this error:
image

somebody can help understand why e how i fix it.

Thank you

Error: Returned error: VM Exception while processing transaction: revert

  Contract: DappToken
    ✓ initializes the contract with the correct values (338ms)
    ✓ sets the total supply upon deployment (259ms)
    1) transfers token ownership
    > No events were emitted


  2 passing (3s)
  1 failing

  1) Contract: DappToken
       transfers token ownership:
     Error: Returned error: VM Exception while processing transaction: revert

I have followed everything in the tutorial and in fact, even copied all the code over and yet I am getting this error. Don't have the slightest clue why this is happening. Any help would be appreciated.

Here is the link to my repo.

token price not showing on the website

Hi,

As the title says, the token price set in the App.js is not showing on the website and is not taken into a count when i buy tokens with ether through metamask.

As anyone got the same issue ?

Issue on purchase

After I select a token for purchase, I get the below error

ALERT: [ethjs-rpc] rpc error with payload {"id":8115156641523,"jsonrpc":"2.0","params":["0xf892058504a817c8008307a12094fc4878e9ab8e9e9278ab6927d9b7b1a73502fe2887038d7ea4c68000a43610724e0000000000000000000000000000000000000000000000000000000000000001822d45a0d540ee24845101bce60f0e962406b5a7a7c18576bea9fa7311287a76bb52c433a0594c832caa47e93b5041fca934938ca23a078ed2cea0b6813d7279b454baf876"],"method":"eth_sendRawTransaction"} Error: VM Exception while processing transaction: revert

Not a contract address

Getting this error while working on Video 63:

Uncaught (in promise) Error: Attempting to run transaction which calls a contract function, but recipient address 0xc9301a4af7c3e531293ae3539dcecfef2507db40 is not a contract address
at Object.InvalidResponse (web3.min.js:1)
at web3.min.js:2
at XMLHttpRequest.n.onreadystatechange (web3.min.js:2)
InvalidResponse @ web3.min.js:1
(anonymous) @ web3.min.js:2
n.onreadystatechange @ web3.min.js:2
Promise.then (async)
render @ app.js:76
(anonymous) @ app.js:43
i @ jquery.min.js:2
fireWith @ jquery.min.js:2
y @ jquery.min.js:4
c @ jquery.min.js:4
XMLHttpRequest.send (async)
send @ jquery.min.js:4
ajax @ jquery.min.js:4
n.(anonymous function) @ jquery.min.js:4
getJSON @ jquery.min.js:4
(anonymous) @ app.js:37
i @ jquery.min.js:2
fireWith @ jquery.min.js:2
y @ jquery.min.js:4
c @ jquery.min.js:4
XMLHttpRequest.send (async)
send @ jquery.min.js:4
ajax @ jquery.min.js:4
n.(anonymous function) @ jquery.min.js:4
getJSON @ jquery.min.js:4
initContracts @ app.js:30
initWeb3 @ app.js:26
init @ app.js:12
(anonymous) @ app.js:102
dispatch @ jquery.min.js:3
r.handle @ jquery.min.js:3
load (async)
add @ jquery.min.js:3
(anonymous) @ jquery.min.js:3
each @ jquery.min.js:2
each @ jquery.min.js:2
sa @ jquery.min.js:3
on @ jquery.min.js:3
(anonymous) @ bootstrap.min.js:6
(anonymous) @ bootstrap.min.js:6

Any idea about this one?

Chrome console showing null account?? Token address is also different

Problem is in the connection of metamask to the local blockchain by using its RPC address. I use the private key of the first account to get its information. But in my system the first account's actual address in ganache is: 0x4DF4F75E96D49A1b61a4Cd1800d55444bb39C761 but the address that is displayed in my chrome console is 0xED4Cd7eA80CfdDef5c78F6A02C9352124AA6D835. Also in app.js in the render function where I have to display my account I am getting account as NULL. Please do confirm why it is different. How do I wire up the actual account to app.js.

Screen Shot 2020-04-04 at 7 10 37 PM

Constructors in Truffle

The thing is when I'm passing an argument in constructor, the truffle migrate (with the --reset ) gives an error which says :

Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: DappToken contract constructor expected 0 arguments, received 1

Solidity code:

constructor(uint256 _totalSuppy) public {
		totalSupply = _totalSuppy ;

2_deploy_contract.js code:

module.exports = function(deployer) {
  deployer.deploy(DappToken , 1000000);
}

I just need want to know if I'm doing anything wrong.
If there is a fix for this do let me know. Thanks in advance.

Uncaught (in promise) TypeError: web3.fromWei(...).toNumber is not a function at app.js:77

toNumber() is not a function however this was working yesterday.

When I load my dev test page in the console I receive the following error:

Uncaught (in promise) TypeError: web3.fromWei(...).toNumber is not a function at app.js:77

` $('.token-price').html(web3.fromWei(App.tokenPrice, 'ether').toNumber());

I also made a change and added
` web3.utils.fromWei(App.tokenPrice, 'ether').toNumber());

However, this comes up as fromWei = undefinied

Test gives wrong indication I guess

Hi Gregory,

you are testing bytoken and checking for error:

return tokenSaleInstance.buyTokens(800000, { from: buyer, value: numberOfTokens * tokenPrice }) }).then(assert.fail).catch(function(error) { assert(error.message.indexOf('revert') >= 0, 'cannot purchase more tokens than available');

As the function checks msg.value as numberOfTokens times price first and you are passing 800.000 as product, I think the raised error comes from incorrect product instead of checked "tokens available" ... am I wrong?

require(msg.value == multiply(_numberOfTokens, tokenPrice)); require(tokenContract.balanceOf(this) >= _numberOfTokens);

best

Timo

Truffle

Tried
" Truffle init " in command prompt but it is not recognized

Where the amount goes off?

I don't understand this part of code:

require(tokenContract.transfer(msg.sender, _numberOfTokens));

the msg.sender sold to himself?

When you calls function from imported contract the msg.sender is address of caller contract (DappTokenSale is this case) ?

  // Buy tokens
  function buyTokens(uint256 _numberOfTokens) public payable {
    // Require that value is equal to tokens
    require(msg.value == multiply(_numberOfTokens, tokenPrice));

    // Require that the contract has enough tokens
    require(tokenContract.balanceOf(address(this)) >= _numberOfTokens);

    // Require that a transfer is successful
    require(tokenContract.transfer(msg.sender, _numberOfTokens));

    // keep track of tokensSold
    tokensSold += _numberOfTokens;

    // Trigger Sell Event
    emit Sell(msg.sender, _numberOfTokens);
  }

Cannot Connect

I followed along with the tutorial, and I am the point of building the front end.

truffle-contract.min.js:380 Uncaught (in promise) Error: DappTokenSale has not been deployed to detected network (network/artifact mismatch)

Uncaught (in promise) Error: DappToken has not been deployed to detected network (network/artifact mismatch)
Uncaught (in promise) Error: DappTokenSale has not been deployed to detected network (network/artifact mismatch)

and keep getting these errors. Even when I clone it done. I have metamask running on my my locahost.

Any Ideas?

How to fix: AssertionError: error message must contain revert

I am trying to make my own cryptocurrency using the DAPPuniversity tutorial, however, my code keeps throwing an exception. I am using the Mac terminal and ATOM text editor. Here is my .sol code:
`pragma solidity >=0.4.21 <0.6.0;

contract Faicoin {
string public name = "Faicoin";
string public symbol = "FAI";
string public standard = "Faicoin v1.0";
uint256 public totalSupply;

event Transfer(
address indexed _from,
address indexed _to,
uint256 _value
);

mapping(address => uint256) public balanceOf;

constructor(uint256 _initialSupply) public {
balanceOf[msg.sender] = _initialSupply;
totalSupply = _initialSupply;
}

function transfer(address _to, uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value);

balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;

emit Transfer(msg.sender, _to, _value);

return true;

}
}
`

Here is my .js code:

`var Faicoin = artifacts.require("./Faicoin.sol");

contract('Faicoin', function(accounts){
var tokenInstance;

it('initalizes the contract with the correct values', function(){
return Faicoin.deployed().then(function(instance) {
tokenInstance = instance;
return tokenInstance.name();
}).then(function(name) {
assert.equal(name, 'Faicoin', 'has the correct name');
return tokenInstance.symbol();
}).then(function(symbol){
assert.equal(symbol, 'FAI', 'has the correct symbol');
return tokenInstance.standard();
}).then(function(standard){
assert.equal(standard, 'Faicoin v1.0', 'has the correct standard');
});
});

it('allocates the initial supply upon deployment', function(){
return Faicoin.deployed().then(function(instance){
tokenInstance = instance;
return tokenInstance.totalSupply();
}).then(function(totalSupply) {
assert.equal(totalSupply.toNumber(), 1000000000, 'sets total supply to 1,000,000,000');
return tokenInstance.balanceOf(accounts[0]);
}).then(function(adminBalance) {
assert.equal(adminBalance.toNumber(), 1000000000, 'allocates the initial supply to the admin account');
});
});

it('transfers token ownership', function() {
return Faicoin.deployed().then(function(instance){
tokenInstance = instance;
return tokenInstance.transfer.call(accounts[1], 9999999999999999)
}).then(assert.fail).catch(function(error){
assert(error.message.indexOf('revert') >= 0, 'error message must contain revert');
return tokenInstance.transfer(accounts[1],250000, {from: accounts[0] });
}).then(function(success) {
assert.equal(success, true, 'it returns true');
return tokenInstance.transfer(accounts[1], 250000, { from: accounts[0] });
}).then(function(receipt) {
assert.equal(receipt.logs.length, 1, 'triggers one event');
assert.equal(receipt.logs[0].event, 'Transfer', 'should be the "Transfer" event');
assert.equal(receipt.logs[0].args._from, accounts[0], 'logs the account the tokens are transferred from');
assert.equal(receipt.logs[0].args._to, accounts[1], 'logs the account the tokens are transferred to');
assert.equal(receipt.logs[0].args._value, 250000, 'logs the transfer amount');
return tokenInstance.balanceOf(accounts[1])
}).then(function(reciept) {
return tokenInstance.balanceOf(accounts[1]);
}).then(function(balance){
assert.equal(balance.toNumber(), 250000, 'adds the amount to the recieving amount');
return tokenInstance.balanceOf(accounts[0]);
}).then(function(balance){
assert.equal(balance.toNumber(), 999750000, 'deducts the amount from the sending account');
});
});
});
`

Here is what the terminal displays
`Compiling ./contracts/Faicoin.sol...
Compiling ./contracts/Migrations.sol...

Contract: Faicoin
✓ initalizes the contract with the correct values (91ms)
✓ allocates the initial supply upon deployment (40ms)
1) transfers token ownership
> No events were emitted

2 passing (197ms)
1 failing

  1. Contract: Faicoin
    transfers token ownership:
    AssertionError: error message must contain revert
    at test/Faicoin.js:38:7
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.