Backend server created in Golang to provide an API interface for interaction with Database.
Merchants (_id, merchant_address, name, description, verified, campaigns)
merchant_address: { type: String, required: true },
name: { type: String, required: true, default: "Merchant" },
description: { type: String },
verified: { type: Boolean, default: true },
campaigns: { type: ObjectId, required: true },
Collections (_id, collection_address, chain, collectionIdentifier, campaigns, cache, totalSupply, cache_last_updated)
collection_address: { type: String, required: true },
chain: { type: String, required: true },
collectionIdentifier: { type: String, required: true },
campaigns: { type: [String], required: true },
cache: { type: Object, required: true },
totalSupply: { type: Number },
cache_last_updated: { type: Date },
Users (address_w3a, address_b)
Campaign (campaign_id, merchant_id, collection_address, start_time, end_time)
Rewards (rewards_id, merchant_id, collection_address, token_id, description, quantity, quantity_used, approved)
[POST] ✅/users/bind/{address_w3a}/{address_to_bind}
Maps the web3Auth wallet address to a wallet that the user owns (one that is used to collect NFTS for example)
AUTH: Caller must be the owner of the account associated to address_w3a
Replaces current binded wallet with address_to_bind.
[GET] /user/nfts/{address_w3a}
Gets all the NFTS
Returns a list of user’s NFTS in the wallet.
Data is populated from request to Tatum
[GET] ✅/user/rewards/{merchant_id}
Gets all the rewards available filtered by the merchant_id
Returns a list of user’s NFTS in the wallet.
Data is populated from request to Tatum
[https://apidoc.tatum.io/#operation/NftGetTokensByAddressErc721]
[PUT] ✅/user/redeem/{rewards_id} Redeems rewards based on rewards_id
Only owner of rewards_id can redeem
returns:
200: Success
400: User is not the owner of reward_id = {reward_id}
400: Reward Id does not exist
400: Reward has been fully redeemed
Reduce quantity by 1, quantity cannot fall below 0 Increase quantity_used by 1
[GET] ✅/merchants
Get list of merchants.
returns:
merchants: Mechant[]
[POST] ✅/merchant/startcampaign
Request to start a campaign with a collection.
Reward {
description: String
quantity: Number
}
body:
{
"merchant_id": 2,
"collection_address": "0x123",
"rewards": [{
"description": "first_reward",
"quantity": 4
},
{
"description": "second_reward",
"quantity": 5
},
{
"description": "third_reward",
"quantity": 3
}
]
}
- Collection owner gets account address of the merchant
- Collection owner logs into the web app
- Collection owner goes to “approve merchant” page
- Collection owner inputs merchant address collected in step 1 & collection address
- Collection owner signs an typed sign with the merchant address and collection address
- Backend verifies if the collection owner is indeed the ownerOf collection address
- If ownerOf() Collection address is equals to the recovered address of the signature, the collection will be binded.
[GET] ✅/merchant/campaigns/{merchant_id} Retrieves all campaigns that a merchant has
returns:
campaigns: Campaign[]
[POST] ✅/collectionowner/add
Adds collection to merchant. Only owner of collection can do this The owner of the collection will be able to approve the merchant to use it to apply discounts. Approval can only happen after merchant has requested for a collaboration
body:
merchant_id: Int
collection_address: String
signature: String
{
"collection_address": "0xCryptoPunks",
"merchant_id": 1,
"start_time": 1650732173,
"end_time": 1650732174
}
returns:
200: Successfully approved campaign
400: Signer is not the collection owner
400: Collection does not exist
400: Invalid Signature
400: No pending campaign
We are exclusively using Web3Auth as the main mode of login and authentication for our application. Using Web3Auth, we are able to allow users to easily on-board our platform with a crypto wallet, letting them directly have access to purchase NFTs that have loyalty rewards.
We improve the current system by creating a binding/mapping feature that binds existing wallets to the Web3Auth account. This is useful for users who already have NFTs in another wallet.