# Bolt for Gasless NFT Minting

[Bolt](https://lightlink.io/bolt) is LightLink's gasless NFT minting plugin.

It leverages LightLink’s [Enterprise Mode](https://docs.lightlink.io/lightlink-protocol/building-on-lightlink/enterprise-mode-overview) for gasless transactions, providing instant, gasless NFT minting for games, rewards, loyalty cards, and more projects wanting to store data on-chain.

Bolt operates by combining AWS Lambda and SQS for seamless serverless function processing, eliminating manual server management.

Simple API integration for developers:&#x20;

1. Developers fill out a form to create a project account and receive an API key.
2. Bolt sets up an ERC721 contract for the project.
3. The project calls Bolt API and passes the NFT metadata.
4. Projects send data to the Bolt API, which maps this data and mints NFTs. Users can specify an address to mint to, or provide a `userId`. If a `userId` is provided rather then an Ethereum address, a unique LightLink account is created for the user.

### Start Using Bolt

Fill out the [form](https://lightlink.io/bolt/join) to set up an ERC721 contract for your application and obtain an API key.

### Implement Bolt API calls to transmit data

{% tabs %}
{% tab title="Curl" %}

```sh
curl --location 'https://bolt-dev.lightlink.io/{PROJECT_ID}/{USER_ID}/mint' \
--header 'x-api-key: {API_KEY}' \
--header 'Content-Type: application/json' \
--data '{
  "name": "Epic Dragon",
  "description": "A rare and powerful dragon NFT.",
  "attributes": [
    {
      "trait_type": "Color",
      "value": "Red"
    },
    {
      "trait_type": "Rarity",
      "value": "Legendary"
    },
    {
      "trait_type": "Power",
      "value": 9001
    },
    {
      "trait_type": "Wingspan",
      "value": "15 meters"
    },
    {
      "trait_type": "Fire Breath",
      "value": "Intense"
    }
  ]
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://bolt-dev.lightlink.io/{PROJECT_ID}/{USER_ID}/mint"

payload = json.dumps({
  "name": "Epic Dragon",
  "description": "A rare and powerful dragon NFT.",
  "attributes": [
    {
      "trait_type": "Color",
      "value": "Red"
    },
    {
      "trait_type": "Rarity",
      "value": "Legendary"
    },
    {
      "trait_type": "Power",
      "value": 9001
    },
    {
      "trait_type": "Wingspan",
      "value": "15 meters"
    },
    {
      "trait_type": "Fire Breath",
      "value": "Intense"
    }
  ]
})
headers = {
  'x-api-key': '{API_KEY}',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n  \"name\": \"Epic Dragon\",\n  \"description\": \"A rare and powerful dragon NFT.\",\n  \"attributes\": [\n    {\n      \"trait_type\": \"Color\",\n      \"value\": \"Red\"\n    },\n    {\n      \"trait_type\": \"Rarity\",\n      \"value\": \"Legendary\"\n    },\n    {\n      \"trait_type\": \"Power\",\n      \"value\": 9001\n    },\n    {\n      \"trait_type\": \"Wingspan\",\n      \"value\": \"15 meters\"\n    },\n    {\n      \"trait_type\": \"Fire Breath\",\n      \"value\": \"Intense\"\n    }\n  ]\n}");
Request request = new Request.Builder()
  .url("https://bolt-dev.lightlink.io/{PROJECT_ID}/{USER_ID}/mint")
  .method("POST", body)
  .addHeader("x-api-key", "{API_KEY}")
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "name": "Epic Dragon",
  "description": "A rare and powerful dragon NFT.",
  "attributes": [
    {
      "trait_type": "Color",
      "value": "Red"
    },
    {
      "trait_type": "Rarity",
      "value": "Legendary"
    },
    {
      "trait_type": "Power",
      "value": 9001
    },
    {
      "trait_type": "Wingspan",
      "value": "15 meters"
    },
    {
      "trait_type": "Fire Breath",
      "value": "Intense"
    }
  ]
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://bolt-dev.lightlink.io/{PROJECT_ID}/{USER_ID}/mint',
  headers: { 
    'x-api-key': '{API_KEY}', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});
```

{% endtab %}
{% endtabs %}

### Default Models

{% tabs %}
{% tab title="Stats" %}

* `gameId`: Game's ID
* `userId`: User's ID
* `payload`: Data payload
* `metadata`: Metadata information
* `tokenId`: Token's ID
  {% endtab %}

{% tab title="User" %}

* `walletAddress`: Wallet's address (Unique)
* `walletId`: Wallet's ID
* `externalId`: External ID
* `gameId`: Game's ID
  {% endtab %}

{% tab title="Token" %}

* `userId`: User's ID
* `gameId`: Game's ID
* `tokenId`: Token's unique string identifier
  {% endtab %}

{% tab title="Game" %}

* `name`: Name of the game
* `contractAddress`: Game's contract address
* `imageUrl`: Image URL for the game
* `mappingKey`: Mapping key for the game
  {% endtab %}
  {% endtabs %}

### Retrieve Data With Endpoints

{% tabs %}
{% tab title="Status" %}

* URL: `/status`
* Method: `GET`
* Response: `{ status: 'ok' }`
  {% endtab %}

{% tab title="User stats" %}

* URL: `/users/:userId/stats`
* Method: `GET`
* URL Parameters: `userId` (required) - ID of the user
* Response:
  * Success: `{ success: true, data: userStats }`
  * Error: `{ error: error message, url: requested URL }`
    {% endtab %}

{% tab title="Game stats" %}

* URL: `/games/:gameId/stats`
* Method: `GET`
* URL Parameters: `gameId` (required) - ID of the game
* Response:
  * Success: `{ success: true, data: gameStats }`
  * Error: `{ error: error message, url: requested URL }`
    {% endtab %}

{% tab title="Users of a game" %}

* URL: `/games/:gameId/users`
* Method: `GET`
* URL Parameters: `gameId` (required) - ID of the game
* Response:
  * Success: `{ success: true, data: users }`
  * Error: `{ error: error message, url: requested URL }`
    {% endtab %}

{% tab title="Mint token" %}

* URL: `/:gameId/:userId/mint/`
* Method: `POST`
* URL Parameters:&#x20;
  * `gameId` (required) - ID of the game
  * `userId` (required) - The users ID, or Ethereum wallet.
* Body: JSON object with metadata payload
* Response:
  * Success: `{ success: true, data: postedStats }`
  * Error: `{ error: error message, url: requested URL, body: sent data }`
    {% endtab %}

{% tab title="Fetch token metadata" %}

* URL: `/metadata/:gameId/:tokenId/`
* Method: `GET`
* URL Parameters:&#x20;
  * `gameId` (required) - ID of the game
  * `gameId` (required) - Numeric ID of the token
* Response:
  * Success: `{ NftMetadata }`
  * Error: `{ error: error message, url: requested URL, body: sent data }`
    {% endtab %}
    {% endtabs %}
