Theta EdgeStore Gateway Alpha

The Theta EdgeStore network is aiming to be an append-only, content-addressing, decentralized key/value storage network for the permanent web. It also acts as a decentralized content delivery network (dCDN) for any type of files.

API

Auth Token

To upload data to Theta EdgeStore, an auth token in the following format must be present in the HTTP request header: [timestamp].[wallet address].[signature], where signature = eth_sign(”Theta EdgeStore Call ${timestamp}”).

A token expires in 24 hours.

Sample code in Javascript (Browser)

if (!window.ethereum) {
  // should not reach here.
  throw 'wallet not installed';
}

const timestamp = Date.now().toString();
const msg = 'Theta EdgeStore Call ' + timestamp; 

const sig = await window.ethereum.request({
  method: 'personal_sign',
  params: [msg, address],
});

const auth_token = timestamp + "." + address + "." + sig;

// 1673992464885.0xec2a725e3855275c0c7cd725bf0dc7be95dca517.0x80a7f6ffc969f33603c532a72469d9e47edf6758c496b7d772210f745b63897a0b0a954fa16ed8aaa1321d7b73a23a6d65ea66bb4b345a6ee79aeb30fd5d8df61c

Sample code in Go

timestamp := now.Unix().UnixMilli()
msg := fmt.Sprintf("Theta EdgeStore Call %s", timestamp)
preSigned := "\x19Ethereum Signed Message:\n" + strconv.Itoa(len(msg)) + msg
sig, _ := wallet.Sign(preSigned)
authToken := fmt.Sprintf("%d.%s.%s", timestamp, wallet.Address(), sig.String())

Upload Data

POST https://api.thetaedgestore.com/api/v2/data

Upload a single file:

curl \
  -H 'x-theta-edgestore-auth: 1673992464885.0xec2a725e3855275c0c7cd725bf0dc7be95dca517.0x80a7f6ffc969f33603c532a72469d9e47edf6758c496b7d772210f745b63897a0b0a954fa16ed8aaa1321d7b73a23a6d65ea66bb4b345a6ee79aeb30fd5d8df61c' \
  -F "file=@/Users/ribao/California.jpeg" \
  https://api.thetaedgestore.com/api/v2/data

Output:

{"key":"0x9678e6e2c10062ac2c845d542d7d62931346b2a0ff18628c7fe28cfe0a097636"}

Upload a directory:

curl \
  -H 'x-theta-edgestore-auth: 1673992464885.0xec2a725e3855275c0c7cd725bf0dc7be95dca517.0x80a7f6ffc969f33603c532a72469d9e47edf6758c496b7d772210f745b63897a0b0a954fa16ed8aaa1321d7b73a23a6d65ea66bb4b345a6ee79aeb30fd5d8df61c' \
  -F "directory=@/Users/ribao/theta-foodcourt/demo_website/index.html;filename=demo_website/index.html" \
  -F "directory=@/Users/ribao/theta-foodcourt/demo_website/pic.jpeg;filename=demo_website/pic.jpeg" \
  -F "directory=@/Users/ribao/theta-foodcourt/demo_website/css/main.css;filename=demo_website/css/main.css" \
  -F "directory=@/Users/ribao/theta-foodcourt/demo_website/nested/second.html;filename=demo_website/nested/second.html" \
  https://api.thetaedgestore.com/api/v2/data

Output:

{"key":"0x5dd30f193e4c46fb95e938b5772050ac502546c5da398e431c2c5e2f05286a30"}

Retrieve Data

Retrieve a single file:

GET https://data.thetaedgestore.com/api/v2/data/0x378f7d9173201617afbe00b71153219f914f1125aff7aff1ad997f6d6c126fb1

To retrieve a file inside a directory, append relative path to the URL:

GET https://data.thetaedgestore.com/api/v2/data/0x5dd30f193e4c46fb95e938b5772050ac502546c5da398e431c2c5e2f05286a30/pic.jpeg