Vehicle Part Origin

TOOLSDOCUMENTSUTILITY

Contract purpose

This smart contract keeps track of a vehicle part origin. It stores the details about the previous owners and also allows the selling of the part (ownership transfer).

Exposed methods and variables

manufacturerName the name of the manufacturer of the piece (given in the constructor). It is assumed that the manufacturer creates the contract.

manufacturerAddress the ethereum address of the manufacturer, given as parameter at contract creation

currentOwner the ethereum address of the current owner (initially is the manufacturer address).

description the description of the vehicle part (given in the constructor)

price this price is set when the current owner wants to sell the piece

forSale this value is set to true if the current owner wants to sell the part

owners returns the address of a previous owner. Can be queried starting from the index 0 until the number of the current owner

partForSale this function allows the current owner to let people know that the vehicle part is up for sale

parameter nametypedetails
_priceintegerthe price asked by the owner for the part

buyPart allows a person to buy the piece by sending to the contract the amount asked by the owner. This function work only after the owner called the previous function. The sent amount will be transferred to the address of the current owner, before setting the new owner and emitting the New Owner event.

changeDescription allows the current owner to change the description of the vehicle part

parameter nametypedetails
newDescriptionstringthe new description of the part

Events

New Owner

parameter nametypedetails
Ownerethereum addressthe address of the new owner
Buy
Reviewed by Modex
Buy Contract Test Contract

Create an account or login to purchase this smart contract