{"id":18966141,"url":"https://github.com/aergoio/libaergo-lua","last_synced_at":"2026-04-22T16:37:48.711Z","repository":{"id":85583072,"uuid":"555012821","full_name":"aergoio/libaergo-lua","owner":"aergoio","description":"Library to interface with Aergo in Lua","archived":false,"fork":false,"pushed_at":"2022-10-21T03:37:53.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-02T08:33:20.729Z","etag":null,"topics":["blockchain","lua","smart-contracts"],"latest_commit_sha":null,"homepage":"","language":"C","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/aergoio.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":"2022-10-20T19:51:33.000Z","updated_at":"2022-10-20T20:27:17.000Z","dependencies_parsed_at":"2023-03-14T03:30:15.374Z","dependency_job_id":null,"html_url":"https://github.com/aergoio/libaergo-lua","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aergoio/libaergo-lua","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aergoio%2Flibaergo-lua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aergoio%2Flibaergo-lua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aergoio%2Flibaergo-lua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aergoio%2Flibaergo-lua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aergoio","download_url":"https://codeload.github.com/aergoio/libaergo-lua/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aergoio%2Flibaergo-lua/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32145870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T15:33:03.595Z","status":"ssl_error","status_checked_at":"2026-04-22T15:30:42.712Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","lua","smart-contracts"],"created_at":"2024-11-08T14:35:57.935Z","updated_at":"2026-04-22T16:37:43.702Z","avatar_url":"https://github.com/aergoio.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libaergo-lua\n\nLibrary to interface with the Aergo blockchain in Lua\n\n\n## Installation\n\nFirst [install libaergo](https://github.com/aergoio/libaergo#dependencies)\n\nThen install this library:\n\n```\ngit clone https://github.com/aergoio/libaergo-lua\ncd libaergo-lua\nmake\nsudo make install\n```\n\n## Usage\n\nHere is an example connecting to the Aergo test network:\n\n```lua\nrequire \"aergo\"\n\nif aergo.connect(\"testnet-api.aergo.io\", 7845) == false then\n  error(\"Error connecting to aergo network\")\nend\n```\n\nAfter the connection is done it is possible to interface with smart contracts.\n\nThere are 2 methods to execute functions on them:\n\n* aergo.query\n* aergo.call\n\n**Queries** are used to execute read-only functions, those that do not change the contract state.\n\nThere is no need for an account to do that.\n\nExample:\n\n```lua\nlocal contract_address = \"AmhcceopRiU7r3Gwy5tmtkk4Z3Px53SfsKBifGMvaSSNiyWrvKYe\"\n\nlocal response = aergo.query(contract_address, \"hello\")\n\nprint(\"Smart Contract Query \", response.success and \"OK\" or \"FAILED\")\nprint(\"Response:\", response.result)\n```\n\n**Calls** are used to execute functions that change the contract state.\n\nThese calls are made using transactions. They require an account with funds (native aergo tokens).\n\nThere are 2 ways to have accounts:\n\n* Using a secret (private) key on your app\n* Using hardware wallet (Ledger Nano)\n\nThe private key is a random 32 bytes string.\n\nBefore making a call we need to get the account state.\n\nExample with a private key:\n\n```lua\nlocal privkey = \"\\xDB\\x85\\xDD\\x0C\\xBA\\x47\\x32\\xA1\\x1A\\xEB\\x3C\\x7C\\x48\\x91\\xFB\\xD2\\xFE\\xC4\\x5F\\xC7\\x2D\\xB3\\x3F\\xB6\\x1F\\x31\\xEB\\x57\\xE7\\x24\\x61\\x76\"\n\nlocal account = aergo.get_account_state(false, privkey)  -- false =\u003e use private key\n\nprint(\"address: \", account.address)\nprint(\"nonce: \", account.nonce)\nprint(\"balance: \", account.balance)\n```\n\nExample with a hardware wallet:\n\n```lua\nlocal account = aergo.get_account_state(true, 0)  -- true =\u003e use hardware wallet, the integer is the account index \u003e= 0\n\nprint(\"address: \", account.address)\nprint(\"nonce: \", account.nonce)\nprint(\"balance: \", account.balance)\n```\n\nAfther the account is initialized it is possible to make a call to a function on the smart contract:\n\n```lua\nlocal receipt = aergo.call(account, contract_address, 'set_name', '[\"Lua!\"]')\n\nprint(\"status: \", receipt.status)\nprint(\"returned: \", receipt.ret)\nprint(\"blockNo: \", receipt.blockNo)\nprint(\"blockHash: \", to_hex(receipt.blockHash))\nprint(\"txIndex: \", receipt.txIndex)\nprint(\"txHash: \", to_hex(receipt.txHash))\nprint(\"contractAddress: \", receipt.contractAddress)\nprint(\"gasUsed: \", receipt.gasUsed)\nprint(\"feeUsed: \", receipt.feeUsed)\n```\n\nWhen using the testnet it is possible to add funds to the account using the [faucet](https://faucet.aergoscan.io/)\n\nWhen using the mainnet you need to acquire aergo tokens\n\nHere is how to transfer aergo tokens to another account programmatically:\n\n```lua\nlocal receipt = aergo.transfer(account, recipient_address, amount)\n\nprint(\"status: \", receipt.status)\nprint(\"returned: \", receipt.ret)\nprint(\"blockNo: \", receipt.blockNo)\nprint(\"blockHash: \", to_hex(receipt.blockHash))\nprint(\"txIndex: \", receipt.txIndex)\nprint(\"txHash: \", to_hex(receipt.txHash))\nprint(\"contractAddress: \", receipt.contractAddress)\nprint(\"gasUsed: \", receipt.gasUsed)\nprint(\"feeUsed: \", receipt.feeUsed)\n```\n\n\n### Working example\n\nYou can check an example code in [test.lua](test.lua)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faergoio%2Flibaergo-lua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faergoio%2Flibaergo-lua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faergoio%2Flibaergo-lua/lists"}