stampchain-io / BTCStampsExplorer

Bitcoin Stamps API / Explorer
https://bitcoinstamps.xyz
GNU Affero General Public License v3.0
1 stars 3 forks source link

Stamp Collections Grouping and Creation #11

Closed reinamora137 closed 3 weeks ago

reinamora137 commented 6 months ago

Need to store stamp collections in the database, and allow users to create them. This will mean having a user login via their wallet to confirm they are (their wallet is) the creator of the stamp they want to add to the collection. Allow them to add the colleciton details and assign the stamp #'s into the collection (this should be referenced by the btc trx hash or the stamp_has in case numbering ever changes.

We will want to get a scrape or a dump of collections from these sites which already have collections created to store in our DB.

Example:

Check if user is creator of: Stamp # 0 , # 1

Add to collection table: Name: Laser Eyes Stamps: {0,1}

This will later be visible on the collections page. This could perhaps be a view where they can select images or perhaps a dropdown box of all the stamps they have created.

CharlesDevo41 commented 5 months ago

Just a clarifying question here, could you point me to the existing format in which collection details are stored if there is one? If not, is there a format that we could use as a base to store this data?

reinamora137 commented 5 months ago

There currently is not a format for these, or a db created yet. Shouldn't be too painful to allow this app to write into the db. Currently it's just a read only proxy connection.

dev4pear commented 4 months ago

I would like to know about detailed table columns for storing stamp collections. Such as "id", "collection name", "creator", etc @reinamora137 And also, to implement this, we need to make backend api and also frontend page for this

reinamora137 commented 4 months ago

this is the table schema for the collections

CREATE TABLE IF NOT EXISTS collections (
  `collection_id` BINARY(16) PRIMARY KEY,
  `collection_name` VARCHAR(255) NOT NULL UNIQUE,
  INDEX (collection_name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_as_ci;

CREATE TABLE IF NOT EXISTS collection_creators (
  `collection_id` BINARY(16),
  `creator_address` VARCHAR(64) COLLATE utf8mb4_bin,
  FOREIGN KEY (collection_id) REFERENCES collections(collection_id),
  FOREIGN KEY (creator_address) REFERENCES creator(address),
  PRIMARY KEY (collection_id, creator_address),
  INDEX (creator_address)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_as_ci;

CREATE TABLE IF NOT EXISTS collection_stamps (
  `collection_id` BINARY(16),
  `stamp` INT,
  FOREIGN KEY (collection_id) REFERENCES collections(collection_id),
  FOREIGN KEY (stamp) REFERENCES StampTableV4(stamp),
  PRIMARY KEY (collection_id, stamp),
  INDEX (stamp)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_as_ci;

example writing into these tables when a collection is created:

-- Insert into collections table
INSERT INTO collections (collection_id, collection_name)
VALUES (UNHEX(MD5('My Collection')), 'My Collection');

-- Insert into collection_creators table
INSERT INTO collection_creators (collection_id, creator_address)
VALUES 
(UNHEX(MD5('My Collection')), 'creator_address_1'),
(UNHEX(MD5('My Collection')), 'creator_address_2');

-- Insert into collection_stamps table
INSERT INTO collection_stamps (collection_id, stamp)
VALUES 
(UNHEX(MD5('My Collection')), 1),
(UNHEX(MD5('My Collection')), 2),
(UNHEX(MD5('My Collection')), 3);