A microservice for uploading files to Lighthouse. To be used with Ocean Uploader Backend.
- π Endpoints
- βοΈ Set Up
- π€ Support
- π£ Roadmap
- π€ Contributing
- π License
- π Associated Projects
Description: Gets a quote in order to store some files
Path: POST /getQuote
Arguments:
{
"type": "filecoin",
"files": [{ "length": 2343545 }, { "length": 2343545 }],
"duration": 4353545453,
"payment": {
"chainId": 1,
"tokenAddress": "0xUSDT_on_ETHERUEM"
},
"userAddress": "0x456"
}
Where:
- type: type of storage desired
- files : array with files length in bytes
- duration: how long to store this files (in seconds)
- payment.chainId: chainId that will be used to make the payment
- payment.token: token that will be used to make the payment
- userAddress: address from which payment is pulled
Returns:
{
"tokenAmount": 500,
"approveAddress": "0x123",
"chainId": 1,
"tokenAddress": "0xUSDT_on_MAINNET",
"quoteId": "xxxx"
}
Where:
- tokenAmount: tokenAmount that needs to be approved
- approveAddress: The address of the microservice that needs to be approved (microservice will do a transferFrom to get the payment)
- chainId: chainId used for payment
- tokenAddress: token that will be used to make the payment
- quoteId: backend server will generate a quoteId
Description: Upload some files
Path: POST /upload
Input:
{
"quoteId": "23",
"nonce": 12345.12345,
"signature": "0x2222",
"files": ["ipfs://xxxx", "ipfs://yyyy"]
}
Microservice will upload files to filecoin and it will take the payment
Returns: 200 OK
if all the pre-checks pass. Upload occurs asynchronously.
Call getStatus
to monitor status.
Description: Gets status for a job
Path: POST /getStatus?quoteId=xxx
Returns:
{
"status": 0
}
Where:
Status | Status Description |
---|---|
0 | No such quote |
99 | Waiting for files to be uploaded by the user |
199 | Inadequate Balance or token Allowance given |
300 | Uploading files to storage |
399 | CID migrated to lighthouse node, creating filecoin deal |
400 | Deal created on filecoin network |
401 | Upload failure |
Description: Gets DDO files object for a job
Path: POST /getLink?quoteId=xxx&nonce=1&signature=0xXXXXX
Input:
{
"quoteId": "23",
"nonce": 12345.12345,
"signature": "0x2222"
}
Where:
- quoteId: quoteId generated by backend server
- nonce: (timestamp) (has to be higher then previous stored nonce for this user)
- signature: user signed hash of SHA256(quoteID+nonce)
Returns:
[
{
"type": "arweave",
"transactionHash": "xxxx"
}
]
Description: Gets history quotes for a certain user
Path: GET /getHistory?userAddress=xxx&nonce=1&signature=0xXXXXX
Input:
{
"userAddress": "0x1234",
"nonce": 12345.12345,
"signature": "0x2222"
}
Where:
- userAddress: wallet address
- nonce: (timestamp) (has to be higher then previous stored nonce for this user)
- signature: user signed hash of SHA256(''+nonce)
Returns:
[
{
"type": "filecoin",
"quoteId": "xxxx",
"userAddress": "0x111",
"chainId": 80001,
"tokenAddress": "0x222",
"tokenAmount": "999999999",
"approveAddress": "0x1234",
"requestId": "xxxx"
}
]
- Populate
.env
or environment variable using a sample from.env.example
export DBS_URL="https://google.com"
export LOCATION_URL="127.0.0.1" #publicly accessable url to this deployed instance or server
export PRIVATE_KEY="d211891bd0cd4b0e3d9dd759cfd9416c305beec61c5e5326f3a533a49de6e607" #privateKey of Approved vendor's Address
export TOKEN="xyvcdcdcddcdcdcd" #bearer token generated by Lighthouse to vendor
export DBS_PING_IN_MINUTES="1" # interval to which the microservice registers with Uploader Backend
# for mySQL: Credentials
export DB_TYPE="mysql"
export USER_SQL="root"
export DATABASE_SQL="test"
export DATANAME_SQL="quote"
export HOST_SQL="127.0.0.1"
export PASSWORD_SQL="pass" #do not include if DB has no password
# for sqlite: Credentials
export DB_TYPE="sqlite"
export DB_STORAGE="db/database.sqlite"
npm start
Run in Plain Node Environment
-
Install dependencies
yarn install
-
Make production build with
yarn build
-
Run build
yarn start
Run as Docker Image
-
Build Docker image
docker build -t filecoin_dbs .
-
Run Docker Image
docker run -p 80:3000 -d filecoin_dbs
Please open issues on github if you need support of have any questions.
Stay tuned for more integrations and services. Follow the issues on github to see the latest development plans.
We welcome contributions in form of bug reports, feature requests, code changes, or documentation improvements. Have a look at our contribution documentation for instructions and workflows:
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.