{"id":22165581,"url":"https://github.com/textileio/demo-basin-server","last_synced_at":"2025-03-24T16:14:15.200Z","repository":{"id":249743258,"uuid":"832259118","full_name":"textileio/demo-basin-server","owner":"textileio","description":"A simple hosted server for sending Basin object storage transactions","archived":false,"fork":false,"pushed_at":"2024-07-23T01:45:02.000Z","size":61,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-29T21:51:04.778Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/textileio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-22T16:36:49.000Z","updated_at":"2024-09-05T11:49:08.000Z","dependencies_parsed_at":"2024-07-23T04:50:46.231Z","dependency_job_id":null,"html_url":"https://github.com/textileio/demo-basin-server","commit_stats":null,"previous_names":["textileio/demo-basin-server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/textileio%2Fdemo-basin-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/textileio%2Fdemo-basin-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/textileio%2Fdemo-basin-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/textileio%2Fdemo-basin-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/textileio","download_url":"https://codeload.github.com/textileio/demo-basin-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245304873,"owners_count":20593626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-02T05:15:36.542Z","updated_at":"2025-03-24T16:14:15.179Z","avatar_url":"https://github.com/textileio.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Basin Demo Server\n\n\u003e A simple server for [Basin](https://github.com/textileio/basin) object storage\n\n## Background\n\nThis demo server allows a backend wallet to \"sponsor\" Basin transactions on behalf of a user. Both pushing and getting objects is supported.\n\n## Usage\n\n### Prerequisites\n\nBefore getting started, you'll need to make sure you're properly set up on the Basin subnet. Start by installing the Basin CLI tool and creating a new wallet:\n\n```sh\ngit clone https://github.com/textileio/basin\nmake build\nmake install\n```\n\nYou can either create a new account _or_ use an existing EVM-style (secp256k1) private key. Creating a new account can be done with the CLI:\n\n```sh\nadm account create\n```\n\nThis logs the private key plus its EVM and FVM address:\n\n```\n{\n  \"private_key\": \"59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d\",\n  \"address\": \"0x70997970c51812dc3a010c7d01b50e0d17dc79c8\",\n  \"fvm_address\": \"t410focmxs4gfdajnyoqbbr6qdniobul5y6oirvks3ia\"\n}\n```\n\nThen, make sure you have a wallet with some tFIL (i.e., on Filecoin Calibration) in it. Head over to the Calibration faucet [here](https://faucet.calibnet.chainsafe-fil.io/), request some tFIL, and then `deposit` it into your subnet account. Once the funds have arrived on the subnet, you'll be able to check your balance:\n\n```sh\nexport PRIVATE_KEY=your_private_key\nadm account deposit 10\nadm account info\n```\n\nWe deposit 10 tFIL into the account and after ~30 minutes (the current constraint imposed on the Calibration -\u003e subnet checkpointing process), you should see the balance updated. That is, be sure to wait until `info` logs the balance!\n\n### Setup\n\nNow, we can get things going. Check out the `env.example` file, update the `PRIVATE_KEY`, and create a new `env` file with these values. There is a provided object store address (`OS_ADDRESS`) that you can use, which has fully public write enabled.\n\n```sh\nexport PRIVATE_KEY=hex_encoded_private_key\nexport LISTEN=127.0.0.1:8081\nexport OS_ADDRESS=t2ymaz2yovxlqplqd53tfuiw4umwpdt7tfmbf3v7q\nexport NETWORK=testnet\n```\n\nIf you'd like to create your own object store, you can do so with the CLI—and be sure the `PRIVATE_KEY` is set before attempting to send transactions!\n\n```sh\nadm os create\n```\n\nBe sure to source the `env` file before running the server:\n\n```sh\nsource env\n```\n\n### Running the server\n\nFirst, build and install the server binary:\n\n```sh\nmake build\nmake install\n```\n\nThen, you can start it with the `env` settings:\n\n```sh\nbasin_server -vv\n```\n\nThe `-vv` enables verbose logging, which can be helpful for debugging:\n\n```sh\n2024-07-20T17:49:27.589-04:00 - INFO Starting server at 127.0.0.1:8081\n2024-07-20T17:50:12.015-04:00 - INFO {\"body\":\"{\\\"multipart/form-data; boundary=------------------------u3Cayud8pzT4bsvlrHH4Z5\\\"}\",\"route\":\"set\"}\n2024-07-20T17:50:14.691-04:00 - INFO {\"client_addr\":\"127.0.0.1:50064\",\"duration_ms\":2676,\"method\":\"POST\",\"path\":\"/set\",\"status\":200}\n2024-07-20T17:50:33.952-04:00 - INFO {\"body\":\"{prefix: Some(\\\"hello/\\\"), delimiter: None, offset: None, limit: Some(10)}\",\"route\":\"list\"}\n2024-07-20T17:50:34.371-04:00 - INFO {\"client_addr\":\"127.0.0.1:50068\",\"duration_ms\":419,\"method\":\"POST\",\"path\":\"/list\",\"status\":200}\n```\n\nThere are two routes enabled:\n\n- `POST /set`: Upload an object to the object store\n- `POST /list`: Get an object from the object store\n\nA maximum value of 100 MB is fixed for the server. Within the `src/server/set.rs` file, you can adjust by changing the `MAX_FILE_SIZE` constant.\n\n### Client requests\n\nTo put a file in the object store, use the `/set` endpoint with multipart form data and fields for the uploading:\n\n- `address`: The address of the requesting user (e.g., for attribution purposes).\n- `key`: Custom key for the object.\n- `file`: The local filepath.\n\n```sh\ncurl -X POST -H 'Content-Type: multipart/form-data' \\\n--form 'address=0x79447b8db3a9d23f7db75ae724ba450b7b8dd7b0' \\\n--form 'key=hello/test' \\\n--form 'file=@test.dat' \\\nhttp://localhost:8081/set\n```\n\nThis will log the transaction information from the Basin subnet:\n\n```json\n{\n  \"data\": \"bafy2bzacedxeu3g3uazqpn2ln7yvyfhc6ilj3vi5bf3h6usvygsxaub7paws4\",\n  \"gas_used\": 4311212,\n  \"hash\": \"1DDBED9D0398C4A7C0B2E0DE99BCE77C34232CC1AD45E9304F990A416ACAF830\",\n  \"height\": \"956895\",\n  \"status\": \"committed\"\n}\n```\n\nYou can list objects in the object store along with a query filters:\n\n- `prefix`: Prefix to filter objects by.\n- `limit`: Maximum number of objects to list.\n- `delimiter`: Delimiter used to define object hierarchy.\n- `offset`: Offset to start listing objects from.\n\n```sh\ncurl -X POST -H 'Content-Type: application/json' \\\n-d '{\"prefix\": \"hello/\", \"limit\": 10}' \\\nhttp://localhost:8081/list\n```\n\nThe response will provide all matching objects under that specific prefix:\n\n```json\n{\n  \"common_prefixes\": [],\n  \"objects\": [\n    {\n      \"key\": \"hello/world\",\n      \"value\": {\n        \"cid\": \"bafybeid3weurg3gvyoi7nisadzolomlvoxoppe2sesktnpvdve3256n5tq\",\n        \"metadata\": {},\n        \"resolved\": true,\n        \"size\": 5\n      }\n    }\n  ]\n}\n```\n\nAlteratively, you can list all objects with default settings by providing no query parameters:\n\n```sh\ncurl -X POST -H 'Content-Type: application/json' \\\nhttp://localhost:8081/list\n```\n\n## Development\n\nLocal development isn't _quite_ enabled yet, so you'll have to use the public Filecoin Calibration testnet and Basin subnet setup.\n\nAll the available Makefile commands include:\n\n- Build all crates: `make build`\n- Install the CLI: `make install`\n- Run linter: `make lint`\n- Run formatter: `make check-fmt`\n- Run clippy: `make check-clippy`\n- Do all of the above: `make all`\n- Clean dependencies: `make clean`\n\nOnly basic `INFO` and `ERROR` logging is implemented. See the `log_request_details` function in `src/server/utils.rs` for more information.\n\n## Contributing\n\nPRs accepted.\n\nSmall note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.\n\n## License\n\nMIT OR Apache-2.0, © 2024 Textile Contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftextileio%2Fdemo-basin-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftextileio%2Fdemo-basin-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftextileio%2Fdemo-basin-server/lists"}