We simulate an art gallery that sells its works of art
Customers can put the purchased works of art on sale and in case of sale the art gallery retains the fees
Etherscan url:
https://goerli.etherscan.io/address/0xE6CB8Df626b9c0CA9E5b37431e48f25F3aFD00f5#code
Artwork
Business
mapping(string => Artwork)
The mapping Artwork is the list of ArtWorks, the mapping key is the ArtWork code
mapping(string => Business[])
The mapping Business[] is a list for every artwork with the operations performed on the artwork,
the last element of the array contains the current Owner address and
the current status, if for sale or purchased
AddArtworkEvent
(string code, uint price); => Triggered when a new Art Work is added to the smart contract
RemoveArtworkEvent
(string code); => Triggered when Owner remove Art Work
PutArtworkForSaleEvent
(string code, uint price); => Triggered when Owner (Customer) put the Art Work for sale
RemoveArtworkForSaleEvent
(string code); => Triggered when Owner (Customer) remove the Art Work from sale
BuyEvent
(string code, uint price, address from); => Triggered when Art Work is sold
SendPaymentEvent
(string code, uint price, address to); => Triggered when Smart Contract send amount to the Art Work Owner (Customer)
ChangeArtworkPriceEvent
(string code, uint price); => Triggered when Owner change Art Work price
addArtwork
(string calldata _code, uint _price, uint _percFee, uint256 id)
The Contract owner insert the Artworks
@ _code: the unique code of the Artwork
@ _price: the price of the Artwork
@ _percFee: the fee applied when a client resells the Artwork
removeArtwork
(string calldata _code)
The Contract owner remove the Artworks, only if the Contract owner is the artwork owner
@ _code: the unique code of the Artwork
buyArtwork
(string memory _code)
Buy a product, the product must be for sale
If the Owner is a Customer the Smart Contract send the amount to the Owner and withholds the fees
@ _code: the product code you want buy
putForSale
(string memory _code, uint _price)
The ArtWork Customer can put the product for sale
@ _code: the product code, the sender must be the current owner
@ _price: the sale price
removeFromSale
(string memory _code)
The ArtWork Customer can remove the artwork for sale
@ _code: the artwork code, the sender must be the current owner
changeSalePrice
(string memory _code, uint _price)
The ArtWork Customer can change the price
@ _code: the artwork code, the sender must be the current owner
@ _price: the new price
getCurrentOwner
(string memory _code)
The current Owner of the Artwork by code
@ _code: the Artwork code
getMovementList
(string memory _code)
Return the list of movements for the Artwork
@ _code: the Artwork code
getBalance
Return the current contract balance
returns:
- Total amount of sold Artwork
- Total amount of direct sold Artwork
- Total amount of fee
- Current contract balance
withdraw
(address payable _to, uint _amount)
Owner can withdraw balance
@ _to: address to send the money to
@ _amount: amount to withdraw
artworkNotExists
(string memory _code)
artworkExists
(string memory _code)
senderIsArtworkOwner
(string memory _code)
senderIsNotArtworkOwner
(string memory _code)
artworkIsForSale
(string memory _code)
artworkIsNotForSale
(string memory _code)
stringNotVoid
(string memory _code)
valueNotZero
(uint _value, string memory _message)