This is an old revision of the document!
An Accessor Method is an Operation defined by Object-Oriented Programming (OOP) providing access to Field Data. There are generally two Accessor Methods defined: get and set. In some Object-Oriented (OO) paradigms, the Accessor methods are further defined as:
Some benefits of using a Mutator Methods include:
The following is a Solidity example of a Smart Contract that uses Getters and Setters.
pragma solidity ^0.4.0;
// A simple smart contract
contract MessageContract
{
string message = "Hello World";
function getMessage() public constant
returns(string)
{ return message;
} // End getMessage
function setMessage(string newMessage) public
{ message = newMessage;
} // End setMessage
} // End MessageContract
Ethereum's Solidity can attribute Methods as View.
selfdestruct via callsGetter Method (i.e., Accessor Methods) are by default view methods.
Ethereum's Solidity can attribute Methods as Pure.
block, tx, msg (msg.sig and msg.data can be read).revert() and require() functions to revert potential state changes if an error occurs.