Smart Contracts

Smart contracts are electronic agreements stored on distributed computers called blockchains. Use the smart contracts API to get details about contracts on the network.

Show contract details

POST /v1

Shows the details of a given smart contract on the network.

curl -v -X POST 'https://share-ddn.formless.xyz/v1' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $API_KEY" \
-d '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "contracts_get_by_id",
    "params": {
        "contract_id": "a4680ff6-715b-4101-8ff4-5a34f32ee3f9"
    }
}'

Headers

Name
Value

Content-Type

application/json

Authorization

Bearer <token>

Body

Name
Type
Description

contract_id

string

The ID of the contract within the Formless Network.

Response

{
    "jsonrpc": "2.0",
    "id": "1",
    "result": {
        "success": true,
        "contract_address": "0xD7130CF117C9BF9D2F335A360AA67D85B9D46089",
        "network_id": 137
    }
}

A contract_address is the location of a smart contract program on a given blockchain. It is similar to a memory address on a single computer, but in this case it is the address within the context of a distributed system. Each blockchain has a globally unique ID called a network_id.

Network ID
Blockchain Name
Description
1

Ethereum

Layer 1 Ethereum blockchain.

10

Optimism

Layer 2 Ethereum blockchain with faster, cheaper transactions.

137

Polygon Proof-of-Stake

Ethereum side chain with faster, cheaper transactions.

Create a smart contract

POST /v1

Creates a smart contract on the network.

curl -L -X POST 'https://share-ddn.formless.xyz/v1' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $API_KEY" \
-d '{
    "jsonrpc": "2.0",
    "id": "2",
    "method": "contracts_create",
    "params": {
        "type": "digital_property_with_revenue_share",
        "network": "optimism",
        "title": "CELEBRITY / BLACK TUXES",
        "description": "80/20 revenue split from Spotify and Apple Music.",
        "creator_name": "Brandon Tory",
        "revenue_source": {
            "distributor": "symphonic",
            "product": {
                "isrc": "GBRKQ2173585",
                "upc": "193872934235"
            }
        },
        "revenue_share": {
            "recipients": {
                 "alice@formless.xyz" : 40,
                 "bob@formless.xyz" : 40
            },
            "community_allocation_percent": 20,
            "community_split_count": 20,
            "distribution_unit": {
                "value": 0.01,
                "currency": "USD"
            }
        }
    }
}'

Headers

Name
Value

Content-Type

application/json

Authorization

Bearer <token>

Body

Name
Type
Description

type

string

The type of smart contract to create. Only digital_property_with_revenue_shareis supported.

network

string

The name of the blockchain. optimismand polygonare supported.

title

string

The title of the digital property, e.g. the track or video name.

description

string

The description of the digital property.

creator_name

string

The name of the creator of the digital property.

revenue_source

dictionary

A dictionary used to specify details for the revenue source connected to the contract.

revenue_share

dictionary

A dictionary used to specify details for the revenue share splits associated with the contract.

Response

{
    "jsonrpc": "2.0",
    "id": "2",
    "result": {
        "status": "success",
        "code": 200,
        "network_id": 10,
        "blockchain_name": "optimism",
        "revenue_share_smart_contract_address": "0x1C4e495B064f46a7BEd02f1BcB436ae3e89a80D8",
        "digital_property_contract_address": "0x509d3d81322aDeAD67DB87B64f6a166C591ea203",
        "digital_property_contract_id": "17af475c-e8f6-492a-8c59-bbd1dac5b18b",
        "join_splits_url": "https://share.formless.xyz/splits/optimism/0x509d3d81322aDeAD67DB87B64f6a166C591ea203"
    }
}

Update smart contract metadata

POST /v1

Updates metadata associated with a smart contract.

curl -L -X POST 'https://share-ddn.formless.xyz/v1' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $API_KEY" \
-d '{
    "jsonrpc": "2.0",
    "id": "2",
    "method": "contracts_metadata_write",
    "params": {
        "contract_id": "6ba309b5-dfd1-4ae7-b6da-f17dcc50aa62",
        "metadata": {
            "preview": {
                "artist": "BRANDON TORY",
                "title": "UNICORN: Life I Chose",
                "description": "80/20 community split from Spotify and Apple Music.",
                "linked_metadata": [
                    {
                        "visible": true,
                        "name": "SPOTIFY",
                        "uri": "https://open.spotify.com/track/6wfkuGstuMRrlBEeS6BYRx"
                    },
                    {
                        "visible": true,
                        "name": "APPLE MUSIC",
                        "uri": "https://music.apple.com/us/song/life-i-chose-feat-landon-knox/1582053243"
                    }
                ]
            }
        }
    }
}'

Headers

Name
Value

Content-Type

application/json

Authorization

Bearer <token>

Body

Name
Type
Description

contract_id

string

The ID of the contract within the Formless Network.

metadata

dictionary

A dictionary containing the metadata fields to update. This dictionary will be merged into any existing metadata and will overwrite any specified attributes.

Response

{
    "jsonrpc": "2.0",
    "id": "2",
    "result": {
        "status": "success",
        "code": 200,
        "message": "Contract metadata updated."
    }
}

Last updated