After creating a token using the Playfix Token API, you need to generate a smart contract for the token, then deploy token smart contract.
To generate a Token contract, you need to connect to MetaMask,. Then send a POST request to /token
endpoint, calling the generateContract
method.
Generate the contract for a token.
If the token already has a contract, it will be overwritten by the newly generated contract.
{
"contract": {
"source": {
"main": "//...",
"imports": {
@opengsn/contracts/src/BaseRelayRecipient.sol: "..."
@opengsn/contracts/src/interfaces/IRelayRecipient.sol: "..."
@openzeppelin/contracts/access/AccessControl.sol: "..."
@openzeppelin/contracts/access/IAccessControl.sol: "..."
@openzeppelin/contracts/governance/utils/IVotes.sol: "..."
@openzeppelin/contracts/governance/utils/IVotes.sol: "..."
@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol: "..."
@openzeppelin/contracts/interfaces/IERC3156FlashLender.sol: "..."
@openzeppelin/contracts/security/Pausable.sol: "..."
@openzeppelin/contracts/token/ERC20/IERC20.sol: "..."
@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol: "..."
@openzeppelin/contracts/token/ERC20/extensions/ERC20FlashMint.sol: "..."
@openzeppelin/contracts/token/ERC20/extensions/ERC20Snapshot.sol: "..."
@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol: "..."
@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol: "..."
@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol: "...
}
},
"abi": "[{...}, {...}, {...}, ...]",
"bytecode": "0x...",
}
}
curl --request POST \
--url https://api.playfix.io/token/<token_name>:generateContract \
--header 'Authorization: Bearer <your_access_token>'
import request
token = "<token_name>"
r = requests.post(
"https://api.playfix.io/token/" + token + ":generateContract",
headers = {
"Authorization": "Bearer <your_access_token>"
}
)
print(r.text)
This generates a smart contract per your specifications in the token creation or update process.
{
"contract": {
"source": {
"main": "//...",
"imports": {
@opengsn/contracts/src/BaseRelayRecipient.sol: "..."
@opengsn/contracts/src/interfaces/IRelayRecipient.sol: "..."
@openzeppelin/contracts/access/AccessControl.sol: "..."
@openzeppelin/contracts/access/IAccessControl.sol: "..."
@openzeppelin/contracts/governance/utils/IVotes.sol: "..."
@openzeppelin/contracts/governance/utils/IVotes.sol: "..."
@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol: "..."
@openzeppelin/contracts/interfaces/IERC3156FlashLender.sol: "..."
@openzeppelin/contracts/security/Pausable.sol: "..."
@openzeppelin/contracts/token/ERC20/IERC20.sol: "..."
@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol: "..."
@openzeppelin/contracts/token/ERC20/extensions/ERC20FlashMint.sol: "..."
@openzeppelin/contracts/token/ERC20/extensions/ERC20Snapshot.sol: "..."
@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol: "..."
@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol: "..."
@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol: "...
}
},
"abi": "[{...}, {...}, {...}, ...]",
"bytecode": "0x...",
}
}