Online vs. Offline Signing
The Renter Storage Upload function also has an offline signing mode. This mode allows DApps to sign for file storage uploads for users not running a BTFS daemon. For example, offline signing enables DApps to use BTT from user crypto wallets (i.e. TronLink) for transacting file storage uploads. This differs from the online signing mode, which requires the DApp to sign with the private key derived from BTFS daemon initialization.
The 4 offline-signing related functions are:
- Offline Sign
- Get Unsigned Data
- Sign Contract Batch
- Get Contract Batch
API Endpoint
http://localhost:5001/api/v1/storage/upload/offline
Input Parameters
Argument | Input Values | Type | Description | Required? |
---|---|---|---|---|
arg | Hash of file uploaded to BTFS node. | string | Add hash of file to upload. | Y |
leaf-hash | "True" or "False" | boolean | Flag to specify given hash(es) is leaf hash(es). Default: "false". | N |
price | Price in μBTT | int64 | Max price Per GB per day of storage in μBTT. | N |
replication-factor | int | Replication factor for the file with erasure coding built-in. Default: "3". | N | |
host-select-mode | score | string | Based on mode to select the host and upload automatically. Default: "score". | N |
host-selection | string | Use only these selected hosts in order on 'custom' mode. Use ',' as delimiter. | N | |
host-search-local | bool | Enable host search under all domains 0.0.0.0 (useful for local test). | N | |
storage-length | Number of days | int | Store file for certain length in days. Default: "30". | N |
Usage
async upload(event) {
const response = this.btfs.upload(
{
Hash: this.state.added_file_hash,
TimeNonce: this.time.toString(),
PrivKey: config.PrivKey,
PeerID: config.PeerID
}
)
try {
for await (const resp of response) {
this.setState({ added_session_id: resp.ID })
}
} catch (err) {
console.error(err)
}
this.displayStatus(event)
}
curl -X POST http://127.0.0.1:5001/api/v1/storage/upload/offline?arg=QmQqiYA6LXehPbMw5UtW3zCWstEZ9mY37QNxss41SspAzG&arg
Response
// Outputs Session ID
{"ID":"4a99a8a0-21a1-4e26-861f-9d725eb06012"}