Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add contracts table #1130

Merged
merged 11 commits into from
Nov 4, 2024
Merged

Add contracts table #1130

merged 11 commits into from
Nov 4, 2024

Conversation

Andrei-Dolgolev
Copy link
Contributor

@Andrei-Dolgolev Andrei-Dolgolev commented Sep 19, 2024

Added contracts and bytecode_storage tables.

Insert examples:

INSERT INTO bytecode_storage (
    id,
    hash,
    bytecode,
    title,
    description,
    abi,
    code,
    data
) VALUES (
    '550e8400-e29b-41d4-a716-446655440000', -- id (UUID)
    'd41d8cd98f00b204e9800998ecf8427e',     -- hash (MD5 hash)
    '0x6060604052341561000f57600080fd5b60...', -- bytecode (Text)
    'Sample Contract',                       -- title (VARCHAR)
    'This is a sample contract.',            -- description (Text)
    '{"inputs":[],"name":"myFunction","outputs":[],"stateMutability":"nonpayable","type":"function"}', -- abi (JSONB)
    'pragma solidity ^0.8.0; contract Sample { function myFunction() public {} }', -- code (Text)
    '{"metadata": "Sample metadata"}'        -- data (JSONB)
);
INSERT INTO ethereum_contracts (
    address,
    deployed_bytecode,
    deployed_bytecode_hash,
    bytecode_storage_id,
    abi,
    deployed_at_block_number,
    deployed_at_block_hash,
    deployed_at_block_timestamp,
    transaction_hash,
    transaction_index,
    name,
    statistics,
    supported_standards,
    created_at,
    updated_at
) VALUES (
    DECODE('abcdefabcdefabcdefabcdefabcdefabcdefabcd', 'hex'), -- address (LargeBinary(20))
    '0x6060604052341561000f57600080fd5b60...', -- deployed_bytecode (Text)
    'd41d8cd98f00b204e9800998ecf8427e',        -- deployed_bytecode_hash (MD5 hash)
    '550e8400-e29b-41d4-a716-446655440000',    -- bytecode_storage_id (UUID)
    '{"inputs":[],"name":"myFunction","outputs":[],"stateMutability":"nonpayable","type":"function"}', -- abi (JSONB)
    12345678,                                  -- deployed_at_block_number (BigInteger)
    '0x9e1c...',                               -- deployed_at_block_hash (VARCHAR)
    1617181920,                                -- deployed_at_block_timestamp (BigInteger)
    '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef', -- transaction_hash (VARCHAR)
    0,                                         -- transaction_index (BigInteger)
    'SampleContract',                          -- name (VARCHAR)
    '{"calls": 100, "transactions": 50}',      -- statistics (JSONB)
    '["ERC20", "ERC721"]',                     -- supported_standards (JSONB)
    NOW(),                                     -- created_at (DateTime)
    NOW()                                      -- updated_at (DateTime)
);

Copy link
Contributor

@kompotkot kompotkot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lg

@Andrei-Dolgolev Andrei-Dolgolev merged commit 6268a83 into main Nov 4, 2024
1 check failed
@Andrei-Dolgolev Andrei-Dolgolev deleted the add-contracts-table branch November 4, 2024 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants