Skip to content

Solidity smart contracts for Dice, DiceBattle, Dice Market, ERC20, Dice Token,

Notifications You must be signed in to change notification settings

lwinxp/IS4302_Lab3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Testing Instructions

DiceTokenMarket steps:

  1. use account A to deploy Dice contract
  2. use account A to deploy DiceToken contract
  3. use account A to deploy DiceTokenMarket contract with arg (Dice contract address, DiceToken contract address, 2)
  4. use account A to execute Dice function add dice with arg (1,2) and value 1 ETH, becomes dice 0
  5. use account A to execute Dice function transfer dice with arg (0, DiceTokenMarket address)
  6. use account A to execute DiceTokenMarket function list dice with arg (0, 3)
  7. use account B to execute DiceToken function getCredit with value 1 ETH
  8. use account B to execute DiceTokenMarket function buy with arg (0)
  9. use any account to check Dice variable dices with arg (0). Prev owner of dice should be DiceTokenMarket contract address and owner of dice should be account B address
  10. use account A to execute DiceToken checkCredit function to see that balance has increased by 3 DT
  11. use account B to execute DiceToken checkCredit function to see that balance has reduced by 5 DT to 95 DT
  • 2 DT was commission fee for DiceMarketToken)

DiceBattle steps:

  1. use account A to deploy Dice contract
  2. use account A to deploy DiceBattle contract with arg (Dice contract address)
  3. use account B to execute Dice function add dice with arg (1,2) and value 1 ether, becomes dice 0
  4. use account B to execute Dice function transfer dice with arg (0, DiceBattle address)
  5. use account B to execute DiceBattle function setBattlePair with arg (account C address, 0)
  6. use account C to execute Dice function add dice with arg (3,4) and value 3 ether, becomes dice 1
  7. use account C to execute Dice function transfer dice with arg (1, DiceBattle address)
  8. use account C to execute DiceBattle function setBattlePair with arg (account B address, 1)
  9. use account C to execute DiceBattle function battle with arg (1, 0, account C address, account B address)
  10. use any account to execute DiceBattle function battleResults with arg (0) to see battle results, including dice1, dice2, player1, player2, winner, and if tie result
  11. use any account to check Dice variable dices with arg (0), and with arg (1). The prev owner of both dice 0 and dice 1 should be the DiceBattle address, and the new owner should be the winner in step 10 or original owner if tie.
  • in console can also see the diceId, newNumber and result event type (winResult, loseResult, tieResult)
  • result event is relative to the account that executed battle function, as account C executed the battle, hence
  • winResult - account C is owner of dice 0 and dice 1
  • loseResult - account B is owner of dice 0 and dice 1
  • tieResult - account B is owner of dice 0 and account C is owner of dice 1

All files and steps are available on Github repo - https://github.com/lwinxp/IS4302_Lab3

About

Solidity smart contracts for Dice, DiceBattle, Dice Market, ERC20, Dice Token,

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published