For every contract deployed or verified on MaticVigil, it automatically generates REST API endpoints over HTTPS which are available as an OpenAPI Specification.
The contract being used for this guide comes bundled with the CLI tool by the name
ERC20MintablePresupplied.sol and implements the standard interface for an ERC20 token contract. The modification introduced is where the Ethereum account that deploys the contract automatically gets a number of minted tokens,
1000000000000000000000000 to be exact.
Ensure you copy over the included library
SafeMath.solfrom the same directory.
On visiting the contract's dashboard, you can find the OpenAPI spec link on the top left corner with a copy button and as well as right above the name of the contract.
Click on the import button in the top left corner and select the
You will see the Contract methods populated as HTTP GET and POST endpoints.
MaticVigil exposes the following as GET endpoints from the Solidity source code of a smart contract
publicmethod that does not alter the state of the contract i.e.
Let us try out a couple of GET calls on the contract that reads the state data on chain.
name of the ERC20 contract#
For example, against the public variable
name, MaticVigil automatically exposes it as a GET endpoint as if it were an accessor.
totalSupply of this ERC20 contract#
This tells us the total tokens in supply through this contract amounts to
MaticVigil exposes the following as POST endpoints from the Solidity source code of a smart contract
publicmethod that alters the state of the contract i.e.
To perform POST calls on MaticVigil API, an HTTP header
X-API-KEY is also expected. This holds the API key(Write) associated with your MaticVigil account
The HTTP request headers are already populated with the necessary parameters, courtesy the tight integration between Postman and OpenAPI Specs. Ensure you put the API key(Write) associated with your account in the header field shown below.
Once entering the necessary body and header request parameters, we complete the HTTP POST to
It returns the transaction hash sent out on the blockchain network corresponding to this request, which is,
We make a call to the public mapping
balanceOf on the ERC20 smart contract that holds a mapping of Ethereum addresses to their allocated tokens. Enter the account address to which the transfer was made in the previous section against the path parameter in Postman.
As you can see, the transfer has resulted in the balance of
0x008604d4997a15a77f00CA37aA9f6A376E129DC5 to be set to
1000, i.e. the value passed to the
transfer method call.