NetworkMarketplace

Introduction

This document represents the specification of a smart contract that deals with managing the creation of relay networks.

Data Structures

Type aliases

Name Type Description Example
CapabilityKey bytes32 Capability name latency, bandwidth, latencySLA, bandwidthSLA, ...
CapabilityValue uint256 Capability value
Protocol bytes32 Supported protocols ETH, BTC .....

Capability

struct Capability {
    CapabilityKey key;
    CapabilityValue value;
}

NetworkData

struct NetworkData {
    Protocol protocol;
    Capability[] capabilities;
    address networkAddress;
}

Storage

networkMap

mapping(bytes32 => NetworkData) networkMap;

Events Emitted

NetworkAdded

event NetworkAdded(bytes32 networkId, Protocol protocol, Capability[] capabilities, address networkAddress);

Functions

getNetworkAddress

Get the address of the network contract based on the network id.

function getNetworkAddress(bytes32 networkId) public view returns(address) {
    return networkMap[networkId].networkAddress;
}

registerNetwork

Create a network if the stake provided by the creator is more than the stake threshold set for the network. Event NetworkCreated is emitted on successful creation of a relay network.

function registerNetwork(Protocol protocol, Capability[] capabilities) public {
    Network network = new Network(msg.sender);
    bytes32 networkId = network.getNetworkId();
    networkMap[networkId] = NetworkData(protocol, capabilities, msg.sender);
    emit NetworkAdded(networkId, protocol, capabilities, msg.sender);
}

Imports

import "network";