Launch ERC1155 Token

Launch an ERC1155 Token with The APIS

Creating an ERC1155 token with APIS is easy - even if you don't know how to write a smart contract yourself. All you'll need is an Ethereum wallet address and an http client… and The APIS, of course!

Here are the 3 endpoints we’ll reference:

POST /api/v1/wallets (create wallet)
GET /api/v1/wallets (read wallet)
POST /api/v1/tokens (create token)

First thing’s first… we need a wallet!

Create Wallet

Use the create wallet endpoint to generate a new Ethereum wallet address and private key. We’ll use this address for launching our token (we can discard it when we’re done if we want — more on that later).

post
Create Wallet

https://api.dev.theapis.io/api/v1/wallets?apiKey=<API_KEY>
Create a new Ethereum wallet.
Request
Response
Request
Query Parameters
apiKey
required
string
Api=key
Body Parameters
chain
required
string
Chain
network
required
string
Network
Response
200: OK
New Wallet
{
"address": "0x13F203310024834C27561c4aa87E303dbe83BA7e",
"privateKey":"0xc166df8768386ecf46dbca60c94371cc887dc3dbbe007c4c22c549477e9f0d7b"
}
# Create wallet
curl \
--location \
--request POST 'https://api.dev.theapis.io/api/v1/wallets?apiKey=<API_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
"chain": "ethereum",
"network": "mainnet"
}'

Fund Wallet

  • Transfer a little Ether to the new account for creating the smart contract

  • Read the balance of the new account using APIS

get
Read Balance

https://api.dev.theapis.io/api/v1/wallets?apiKey=<API_KEY>&chain=ethereum&network=rinkeby&address=<MY_ADDRESS>
Read the balance of an Ethereum address
Request
Response
Request
Query Parameters
apiKey
required
string
Api-key
chain
required
string
Chain
network
required
string
Network
address
required
string
Address
Response
200: OK
{
"balances": {
"ETH": {
"balance": "0",
"uiBalance": "0"
}
}
}
curl "https://api.dev.theapis.io/api/v1/wallets?apiKey=<API_KEY>&chain=ethereum&network=rinkeby&address=<MY_ADDRESS>"

Create ERC1155 Token Contract

Now, the magic. Use the createToken endpoint to launch the APIS ERC1155 token into both Ethereum and Binance smart chain with the following params: chain , uri, sender (address which can mint the ERC1155 tokens), name and symbol (token symbol, in this case, APIS), and it returns the transaction hash (nice-to-have: return contract address). You can launch tokens on both Ethereum and Binance Smart chain from the same endpoint, Only need to specify the chain params accordingly

For Ethereum, chain : "ethereum" and for Binance Smart chain, chain : "binance_smart_chain"

Note: You may want to have a second, offline-generated address when working with the Ethereum mainnet, to provide as the minter and account. This way, the tokens are all owned by the offline wallet.

# Create token
curl \
--location \
--request POST 'https://api.dev.theapis.io/api/v1/tokens?apiKey=<API_KEY>&chain=ethereum&network=rinkeby' \
--header 'Content-Type: application/json' \
--data-raw '{
"chain": "ethereum",
"network": "mainnet",
"token": {
"name": "The APIS",
"symbol": "API",
"uri": "<token uri>",
},
"type": "APIS_ERC1155",
"sender": "<MY_ADDRESS>",
"privateKey": "<MY_PRIVATE_KEY>"
}'

Check Balance

Now that we’ve launched our contract, you can verify the tokens are there with an API call.

We must wait a short time for the block to be mined

curl https://api.theapis.io/api/v1/tokens/address=<MY_ADDRESS|MY_OFFLINE_ADDRESS>/erc1155/balance?tokenAddress=<RETURNED_APISERC721_TOKEN_ADDRESS>&type=erc1155&apiKey=<API_KEY>&chain=ethereum&network=rinkeby

Voila! We have tokens, we have contracts, we have a new way to build on blockchain.