Approve Collateral
Allowing SmartPiggies to hold the collateral
A first step which must be observed before buying, selling, or creating any piggies is to approve the collateral that is to be transacted in. When creating a smart piggy, collateral is transferred from the creator's account to the SmartPiggies' smart contract.
In order for this to take place, the SmartPiggies smart contract must be authorized to make this transfer. In addition to this interaction, all purchases of piggies on auction are denominated in the collateral locked in the piggy. For example, if a piggy pays DAI, when a piggy is on auction, the auction premium is paid in DAI. Consequently, the buyer must approve the collateral to be sent from their account to the seller's account. This is facilitated by the SmartPiggies smart contract, and therefore the buyer must first approve the collateral token that will be used for payment, before the purchase can be executed.
To approve collateral, switch the toggle next to the desired token listed under the Manage Wallet dropdown menu:
The Manage Wallet menu will list all collateral tokens available on the SmartPiggies application. In the above graphic, Truffle Token
is approved. Any unapproved token will show the toggle in the left position. To make the approval, click on the toggle, and confirm the transaction. This transaction will cost a small fee, however, the transaction will "approve" a large enough amount of tokens, which allows these approval transactions to be made sparingly. Once the approval amount is depleted (this amount is reduced during each transfer), an approval will need to be made again.
The SmartPiggies application will only list certain collateral tokens. These tokens have been tested, and authorized for use on the SmartPiggies platform. It is recommended to use only homologated tokens with SmartPiggies, however any ERC20 token, that includes a decimals() function, can be used.
Note that an approval must be made for each collateral token a user may want to participate with. If a buyer wants to buy a piggy that holds DAI and another that holds USDC, an approval must be made for both DAI and USDC.


1 Tokens are technically not sent to the SmartPiggies smart contract. Technically ownership rights are just transferred on the token's smart contract. In this example, the ownership rights of the token are changed from the creator/writer to the SmartPiggies smart contract. When the creator withdraws the collateral after settlement, the ownership rights of the tokens are assigned back to the creator's Ethereum account.
2 Again, technically the buyer doesn't "send" tokens to the seller. In an auction, the ownership rights of the tokens are updated on the smart contract of the specific ERC20 token being used.
3 Truffle Token is a SmartPiggies ERC20 token primarily used for testing at this phase. There are additional uses being explored by the team for these tokens, but at this stage these tokens are purely used for educational purposes.
Copy link