Skip to content

sergioneo/unicornsvsdinosaurs-smartcontracts

Repository files navigation

Unis vs Dinos

Contracts relationship

Alt text

Simple reference to use truffle and testrpc

The Hitchhiker’s Guide to Smart Contracts in Ethereum

Simple reference to debug with truffle

DEBUGGING A SMART CONTRACT

Test

1. testrpc ( local ethereum blockchain )

Install and start testrpc

$ npm install -g ethereumjs-testrpc
$ testrpc

2. Truffle

*Note: All the values are in wei, you can use this to transform to wei ETH Calculator

Install truffle

$ npm install -g truffle

Clone this proyect

$ git clone ...

Open truffle console develop in proyect directory

truffle develop

In console, migrate the contracts

migrate --reset

List the address of this local test blockchain

var accounts;
web3.eth.getAccounts(function(err,res) { accounts = res; });
var account1 = accounts[0];
var account2 = accounts[1];

Set the address of Auction contract

Legends.deployed().then(function(instance){return instance.setSaleAuctionAddress(SaleClockAuction.address);});

Buy a Legend gen0 with Random Attrs ( like a loot box )

Legends.deployed().then(function(instance){return instance.buyRandomLegend({value:300000000000000000});});

Put a legend in auction

Legends.deployed().then(function(instance){return instance.legendToMarket(2, 300000000000000000, 300000000000000000);});

Get the detail of an auction

SaleClockAuction.deployed().then(function(instance){return instance.getAuction(2);});

Bid ( buy ) a Legend from in auction

SaleClockAuction.deployed().then(function(instance){return instance.bid(2, {value:300000000000000000, from: account2});});

List number of Legends of each account

Legends.deployed().then(function(instance){return instance.balanceOf(account1);});
Legends.deployed().then(function(instance){return instance.balanceOf(account2);});

List id of Legends owned by an address

Legends.deployed().then(function(instance){return instance.tokensOfOwner(account1);});
Legends.deployed().then(function(instance){return instance.tokensOfOwner(account2);});

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •