{"id":24770326,"url":"https://github.com/petrosdemetrakopoulos/ethairballoons","last_synced_at":"2025-09-19T22:29:30.643Z","repository":{"id":42813317,"uuid":"236570391","full_name":"petrosDemetrakopoulos/ethairballoons","owner":"petrosDemetrakopoulos","description":"A strictly typed ORM library for Ethereum blockchain. ","archived":false,"fork":false,"pushed_at":"2024-03-27T21:58:33.000Z","size":15149,"stargazers_count":40,"open_issues_count":4,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-15T00:50:21.081Z","etag":null,"topics":["blockchain","dao","dapp","database","ethereum","ethereum-blockchain","javascript","javascript-library","library","orm","smart-contracts"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/petrosDemetrakopoulos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-01-27T19:07:53.000Z","updated_at":"2024-04-21T21:53:26.000Z","dependencies_parsed_at":"2023-11-20T21:25:42.912Z","dependency_job_id":"b447911b-4b4f-490f-ab15-6f6ec46fb094","html_url":"https://github.com/petrosDemetrakopoulos/ethairballoons","commit_stats":{"total_commits":185,"total_committers":3,"mean_commits":"61.666666666666664","dds":0.08648648648648649,"last_synced_commit":"f3ad5d656e53b76eacefe799f450f9c2e690576c"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petrosDemetrakopoulos%2Fethairballoons","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petrosDemetrakopoulos%2Fethairballoons/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petrosDemetrakopoulos%2Fethairballoons/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petrosDemetrakopoulos%2Fethairballoons/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/petrosDemetrakopoulos","download_url":"https://codeload.github.com/petrosDemetrakopoulos/ethairballoons/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236126450,"owners_count":19098948,"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":["blockchain","dao","dapp","database","ethereum","ethereum-blockchain","javascript","javascript-library","library","orm","smart-contracts"],"created_at":"2025-01-29T03:37:25.531Z","updated_at":"2025-09-19T22:29:25.585Z","avatar_url":"https://github.com/petrosDemetrakopoulos.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EthAir Balloons\n\u003cimg src=\"https://raw.githubusercontent.com/petrosDemetrakopoulos/ethairballoons/master/logo_official.png\" width=\"300\"\u003e\n\n\nA strictly typed ORM library for Ethereum blockchain.\nIt allows you to use Ethereum blockchain as a persistent storage in an organized and model-oriented way \u003cstrong\u003ewithout writing custom complex Smart contracts\u003c/strong\u003e.\n\n\n\u003cstrong\u003eNote:\nAs transaction fees may be huge, it is strongly advised to only deploy EthAir Balloons models in private Ethereum blockchains or locally using\n`ganache-cli` .\n\u003c/strong\u003e\n\n\n# Installation\n```\nnpm i --save ethairballoons\n```\n\n# Setup\n\n```JS\nconst ethAirBalloons = require('ethairballoons');\nconst path = require('path');\nlet savePath = path.resolve(__dirname + '/contracts');\n\nconst ethAirBalloonsProvider = ethAirBalloons('http://localhost:8545', savePath);\n//ethereum blockchain provider URL, path to save auto generated smart contracts\n\nconst Car = ethAirBalloonsProvider.createSchema({\n    name: \"Car\",\n    contractName: \"carsContract\",\n    properties: [{\n            name: \"model\",\n            type: \"bytes32\",\n            primaryKey: true\n        },\n        {\n            name: \"engine\",\n            type: \"bytes32\",\n        },\n        {\n            name: \"cylinders\",\n            type: \"uint\"\n        }\n    ]\n});\n\n```\n\nAs you can see you can very easily create a new ethAirBaloons provider (line 3) by setting only 2 arguments.\n1) the URL of the Ethereum blockchain provider that you want to use\n(in the example it is set to a local `ganache-cli` provider),\n2) the path where you want to save the automatically generated smart contracts of your models.\n\nAfter you create the provider you can create new data schemas using the `createSchema()` function and pass the schema details in JS object format.\nOf course you can (an it is advised) keep the schema definitions in separate .JSON files and then import them using the `require()` statement in the top of your file.\n\n\n `createSchema()` returns a  `Schema` object.\n In order to successfully initialize a `Schema` object, *only one* property\n of the schema definition must have `primaryKey` field set to `true` (as shown in the example above)\n and the `type` field must be set to one of the legal [Solidity data types](https://solidity.readthedocs.io/en/v0.5.3/types.html).\n\n # Functions of `Schema` object\n`Schema` object implements all the functions needed to perform CRUD operations.\nAs all blockchains have an asynchronous nature, all functions in the library return a callback function.\nAfter you initialize a `Schema`, you can call the following functions:\n\ndeploy()\n--------\nIt is the fist function that you must call in order to set your model up \"up and running\".\nThis function generates the solidity Smart contract of your model and it deploys\nit in the Ethereum based blockchain that you have set in the first step.\nIt returns a boolean indicating if the deploy is successfull and an error object that will be undefined if the deploy is successfull.\nAfter deploy completes you can call the other functions.\n\nExample:\n\n```JS\nCar.deploy(function (err, success) {\n    if (!err) {\n        console.log('Deployed successfully');\n    }\n});\n```\n\nsave()\n------\nSaves a new record in th blockchain. Make sure to set the primary key field in the object you want to save, otherwise an error will be returned.\nIt returns the saved object and an error object that will be undefined if the object is saved successfully.\n\nExample:\n ```JS\nconst newCarObject = {model:'Audi A4', engine: 'V8', wheels: 4};\nCar.save(newCarObject, function (err, objectSaved) {\n    if (!err) {\n        console.log('object saved');\n    }\n});\n```\n\nfind()\n------\nReturns all the records of our Schema.\nExample:\n ```JS\nCar.find(function (err, allRecords) {\n    if (!err) {\n        console.log(allRecords);\n    }\n});\n```\n\nfindById()\n----------\nReturns the record with a specific primary key value if exists.\nOtherwise it will return an error object mentioning that 'record with this id does not exist'.\n\nExample:\n ```JS\nCar.findById('Audi A4', function (err, record) {\n    if (!err) {\n        console.log(record);\n    }\n});\n```\n\n\ndeleteById()\n------------\nDeletes the record with a specific primary key value if exists.\nOtherwise it will return an error object mentioning that 'record with this id does not exist'.\n\nExample:\n ```JS\nCar.deleteById('Audi A4', function (err, success) {\n    if (!err) {\n        console.log('object deleted successfully');\n    }\n});\n```\n\nupdateById()\n------------\nUpdates the record with a specific primary key value if exists.\nOtherwise it will return an error object mentioning that 'record with this id does not exist'.\nIt returns the updated record.\n\nThe first parameter is the primary key value of the record we want to update.\nThe second parameter is the updated object.\nNote that is contrary with save() function it is not necessary to set the primary key field and if you do so, it will NOT be updated.\nIf you want to reassign a stored record to a different id you must first delete it and then save a new one with the different primary key value.\n\nExample:\n ```JS\nconst updatedCarObject = { engine: 'V9', wheels: 4 };\nCar.updateById('Audi A4', updatedCarObject, function (err, updatedObject) {\n    if (!err) {\n        console.log('object updated successfully');\n    }\n});\n```\n\nsetAccount(account)\n------------\nWith this function you can explicitly set the ETH account that you want to use for the model.\nIf not set, account is set by default to the first account of the provider.\n\n# Example project\nYou can find a detailed and documented example project that implement a REST API for CRUD operations in the ethereum blockchain through EthairBalloon models in [this Github repo](https://github.com/petrosDemetrakopoulos/ethairballoons-CRUD-API)\n\n# Tests\nYou can run tests by typing `npm test` in the root directory of the library.\n\n# License\nEthAir Balloons are licensed under MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetrosdemetrakopoulos%2Fethairballoons","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpetrosdemetrakopoulos%2Fethairballoons","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetrosdemetrakopoulos%2Fethairballoons/lists"}