{"id":21616382,"url":"https://github.com/rootsoft/algorand-php","last_synced_at":"2025-04-11T07:33:46.251Z","repository":{"id":42930552,"uuid":"343106572","full_name":"RootSoft/algorand-php","owner":"RootSoft","description":"Unofficial community SDK to interact with the Algorand network, in PHP \u0026 Laravel","archived":false,"fork":false,"pushed_at":"2022-10-07T19:47:06.000Z","size":918,"stargazers_count":41,"open_issues_count":6,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-03-24T05:21:37.806Z","etag":null,"topics":["algorand","algorand-standard-assets","blockchain","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/RootSoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-28T13:01:47.000Z","updated_at":"2023-12-14T07:14:00.000Z","dependencies_parsed_at":"2022-09-07T04:51:20.064Z","dependency_job_id":null,"html_url":"https://github.com/RootSoft/algorand-php","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RootSoft%2Falgorand-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RootSoft%2Falgorand-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RootSoft%2Falgorand-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RootSoft%2Falgorand-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RootSoft","download_url":"https://codeload.github.com/RootSoft/algorand-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248358923,"owners_count":21090448,"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":["algorand","algorand-standard-assets","blockchain","php"],"created_at":"2024-11-24T22:14:21.282Z","updated_at":"2025-04-11T07:33:46.181Z","avatar_url":"https://github.com/RootSoft.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e \n\u003cimg src=\"https://miro.medium.com/max/700/1*BFpFCJepifaREIg7qLSLag.jpeg\"\u003e\n\u003c/p\u003e\n\n# algorand-php\n[![Packagist][packagist-shield]][packagist-url]\n[![Downloads][downloads-shield]][downloads-url]\n[![Issues][issues-shield]][issues-url]\n[![MIT License][license-shield]][license-url]\n\nAlgorand is a public blockchain and protocol that aims to deliver decentralization, scale and security for all participants.\nTheir PURE PROOF OF STAKE™ consensus mechanism ensures full participation, protection, and speed within a truly decentralized network. With blocks finalized in seconds, Algorand’s transaction throughput is on par with large payment and financial networks. And Algorand is the first blockchain to provide immediate transaction finality. No forking. No uncertainty. \n\n\n## Introduction\nAlgorand-php is a community SDK with an elegant approach to connect your application to the Algorand blockchain, send transactions, create assets and query the indexer with just a few lines of code.\n\nOnce installed, you can simply connect your application to the blockchain and start sending payments\n\n```php\n$algorand-\u003esendPayment($account, $recipient, Algo::toMicroAlgos(10), 'Hi');\n```\n\nor create a new asset:\n\n```php\n$algorand-\u003eassetManager()-\u003ecreateNewAsset($account, 'PHPCoin', 'PHP', 500000, 2);\n```\n\n## Features\n* Algod\n* Indexer\n* KMD\n* Transactions\n* Key registration\n* Authorization\n* Atomic Transfers\n* Account management\n* Asset management\n* Smart contracts\n* Laravel support :heart:\n\n## Getting started\n\n### Installation\n\u003e **Note**: Algorand-php requires PHP 7.4+\n\nYou can install the package via composer:\n\n```bash\ncomposer require rootsoft/algorand-php\n```\n\n## Usage\nCreate an ```AlgodClient```, ```IndexerClient``` and ```KmdClient``` and pass them to the ```Algorand``` constructor.\nWe added extra support for locally hosted nodes \u0026 third party services (like PureStake).\n\n```php\n$algodClient = new AlgodClient(PureStake::MAINNET_ALGOD_API_URL, 'YOUR-API-KEY');\n$indexerClient = new IndexerClient(PureStake::MAINNET_INDEXER_API_URL, 'YOUR-API-KEY');\n$kmdClient = new KmdClient('127.0.0.1', 'YOUR-API-KEY');\n$algorand = new Algorand($algodClient, $indexerClient, $kdmClient);\n```\n\n### Laravel :heart:\nWe've added special support to make the life of a Laravel developer even more easy!\n\nPublish the ```algorand.php``` config file using:\n```\nphp artisan vendor:publish --provider=\"Rootsoft\\Algorand\\AlgorandServiceProvider\" --tag=\"config\"\n```\n\nOpen the ```config/algorand.php``` file in your project and insert your credentials\n\n```php\nreturn [\n    'algod' =\u003e [\n        'api_url' =\u003e 'https://testnet-algorand.api.purestake.io/ps2',\n        'api_key' =\u003e 'YOUR API KEY',\n        'api_token_header' =\u003e 'x-api-key',\n    ],\n    'indexer' =\u003e [\n        'api_url' =\u003e 'https://testnet-algorand.api.purestake.io/idx2',\n        'api_key' =\u003e 'YOUR API KEY',\n        'api_token_header' =\u003e 'x-api-key',\n    ],\n    'kmd' =\u003e [\n        'api_url' =\u003e '127.0.0.1',\n        'api_key' =\u003e '',\n        'api_token_header' =\u003e 'X-KMD-API-Token',\n    ],\n];\n```\n\nNow you can use the ```Algorand``` Facade!\n\n```php\nAlgorand::sendPayment($account, $recipient, Algo::toMicroAlgos(10), 'Hi');\n```\n\n## Account Management\nAccounts are entities on the Algorand blockchain associated with specific onchain data, like a balance. An Algorand Address is the identifier for an Algorand account.\nYou can use the ```AccountManager``` to perform all account related tasks.\n\n### Creating a new account\n\nCreating a new account is as easy as calling:\n```php\n$account = $algorand-\u003eaccountManager()-\u003ecreateNewAccount();\n```\n\nWith the given account, you can easily extract the public Algorand address, signing keys and seedphrase/mnemonic.\n```php\n$address = $account-\u003egetPublicAddress();\n$seedphrase = $account-\u003egetSeedPhrase();\n```\n\n### Loading an existing account\n\nYou can load an existing account using your **generated secret key or binary seed**.\n\n```php\n$algorand-\u003eaccountManager()-\u003eloadAccountFromSecret('secret key');\n$algorand-\u003eaccountManager()-\u003eloadAccountFromSeed(hex2bin($seed));\n```\n\n### Restoring an account\n\nRecovering an account from your 25-word mnemonic/seedphrase can be done by passing an **array or space delimited string**\n\n```php\n$account = Algorand::accountManager()-\u003erestoreAccount($seedphrase);\n```\n\n## Transactions\nThere are multiple ways to create a transaction. We've included helper functions to make our life easier.\n\n```php\n$algorand-\u003esendPayment($account, $recipient, Algo::toMicroAlgos(10), 'Hi');\n```\n\nOr you can use the ```TransactionBuilder``` to create more specific, raw transactions:\n\n```php\n// Create a new transaction\n$transaction = TransactionBuilder::payment()\n    -\u003esender($account-\u003egetAddress())\n    -\u003enote('Algonauts assemble!')\n    -\u003eamount(Algo::toMicroAlgos(1.2)) // 5 Algo\n    -\u003ereceiver($recipient)\n    -\u003euseSuggestedParams(Algorand::client())\n    -\u003esuggestedFeePerByte(10)\n    -\u003ebuild();\n\n// Sign the transaction\n$signedTransaction = $transaction-\u003esign($account);\n\n// Send the transaction\n$transactionId = $algorand-\u003esendTransaction($signedTransaction);\n```\n\n## Atomic Transfer\nAn Atomic Transfer means that transactions that are part of the transfer either all succeed or all fail.\nAtomic transfers allow complete strangers to trade assets without the need for a trusted intermediary,\nall while guaranteeing that each party will receive what they agreed to.\n\nAtomic transfers enable use cases such as:\n\n* **Circular trades** - Alice pays Bob if and only if Bob pays Claire if and only if Claire pays Alice.\n* **Group payments** - Everyone pays or no one pays.\n* **Decentralized exchanges** - Trade one asset for another without going through a centralized exchange.\n* **Distributed payments** - Payments to multiple recipients.\n\nAn atomic transfer can be created as following:\n\n```php\n// Create a new transaction\n$transaction1 = TransactionBuilder::payment()\n    -\u003esender($accountA-\u003egetAddress())\n    -\u003enote('Atomic transfer from account A to account B')\n    -\u003eamount(Algo::toMicroAlgos(1.2)) // 5 Algo\n    -\u003ereceiver($accountB-\u003egetAddress())\n    -\u003euseSuggestedParams($algorand)\n    -\u003ebuild();\n\n// Create a new transaction\n$transaction2 = TransactionBuilder::payment()\n    -\u003esender($accountB-\u003egetAddress())\n    -\u003enote('Atomic transfer from account B to account A')\n    -\u003eamount(Algo::toMicroAlgos(2)) // 5 Algo\n    -\u003ereceiver($accountA-\u003egetAddress())\n    -\u003euseSuggestedParams($algorand)\n    -\u003ebuild();\n\n// Combine the transactions and calculate the group id\n$transactions = AtomicTransfer::group([$transaction1, $transaction2]);\n\n// Sign the transaction\n$signedTransaction1 = $transaction1-\u003esign($accountA);\n$signedTransaction2 = $transaction2-\u003esign($accountB);\n\n// Assemble transactions group\n$signedTransactions = [$signedTransaction1, $signedTransaction2];\n\n$algorand-\u003esendTransactions($signedTransactions);\n```\n\n## Asset Management\n\n**Create a new asset**\n\nCreating a new asset is as simple as using the ```AssetManager``` included in the Algorand SDK:\n\n```php\n$algorand-\u003eassetManager()-\u003ecreateNewAsset($account, 'Laracoin', 'LARA', 500000, 2);\n```\n\nOr as usual, you can use the ```TransactionBuilder``` to create your asset:\n\n```php\n// Create a new asset\n$transaction = TransactionBuilder::assetConfig()\n    -\u003eassetName($assetName)\n    -\u003eunitName($unitName)\n    -\u003etotalAssetsToCreate(BigInteger::of($totalAssets))\n    -\u003edecimals($decimals)\n    -\u003edefaultFrozen($defaultFrozen)\n    -\u003emanagerAddress($managerAddress)\n    -\u003ereserveAddress($reserveAddress)\n    -\u003efreezeAddress($freezeAddress\n    -\u003eclawbackAddress($clawbackAddress )\n    -\u003esender($address)\n    -\u003esuggestedParams($params)\n    -\u003ebuild();\n\n// Sign the transaction\n$signedTransaction = $transaction-\u003esign($account);\n\n// Broadcast the transaction on the network\n$algorand-\u003esendTransaction($signedTransaction);\n```\n\n**Edit an asset**\n\nAfter an asset has been created only the manager, reserve, freeze and clawback accounts can be changed.\nAll other parameters are locked for the life of the asset.\n\nIf any of these addresses are set to \"\" that address will be cleared and can never be reset for the life of the asset.\nOnly the manager account can make configuration changes and must authorize the transaction.\n\n```php\n$algorand-\u003eassetManager()-\u003eeditAsset(14192345, $account, $newAccount-\u003egetAddress());\n```\n\n**Destroy an asset**\n\n```php\n$algorand-\u003eassetManager()-\u003edestroyAsset(14192345, $account);\n```\n\n**Opt in to receive an asset**\n\nBefore being able to receive an asset, you should opt in\nAn opt-in transaction is simply an asset transfer with an amount of 0, both to and from the account opting in.\nAssets can be transferred between accounts that have opted-in to receiving the asset.\n\n```php\n$algorand-\u003eassetManager()-\u003eoptIn(14192345, $newAccount);\n```\n\n**Transfer an asset**\n\nTransfer an asset from the account to the receiver.\nAssets can be transferred between accounts that have opted-in to receiving the asset.\nThese are analogous to standard payment transactions but for Algorand Standard Assets.\n\n```php\n$algorand-\u003eassetManager()-\u003etransfer(14192345, $account, 1000, $newAccount-\u003egetAddress());\n```\n\n**Freeze an asset**\n\nFreezing or unfreezing an asset requires a transaction that is signed by the freeze account.\n\nUpon creation of an asset, you can specify a freeze address and a defaultfrozen state.\nIf the defaultfrozen state is set to true the corresponding freeze address must issue unfreeze transactions,\nto allow trading of the asset to and from that account.\nThis may be useful in situations that require holders of the asset to pass certain checks prior to ownership.\n\n```php\n$algorand-\u003eassetManager()-\u003efreeze(14192345, $account, $newAccount-\u003egetAddress(), false);\n```\n\n**Revoking an asset**\n\nRevoking an asset for an account removes a specific number of the asset from the revoke target account.\nRevoking an asset from an account requires specifying an asset sender (the revoke target account) and an\nasset receiver (the account to transfer the funds back to).\n\n```php\n$algorand-\u003eassetManager()-\u003erevoke(14192345, $account, 1000, $newAccount-\u003egetAddress());\n```\n\n## Stateless Smart Contracts\n\nMost Algorand transactions are authorized by a signature from a single account or a multisignature account.\nAlgorand’s stateful smart contracts allow for a third type of signature using a\nTransaction Execution Approval Language (TEAL) program, called a logic signature (LogicSig).\nStateless smart contracts provide two modes for TEAL logic to operate as a LogicSig,\nto create a contract account that functions similar to an escrow or to delegate signature authority to another account.\n\n### Contract Account\n\nContract accounts are great for setting up escrow style accounts where you want to limit withdrawals or you want to do periodic payments, etc.\nTo spend from a contract account, create a transaction that will evaluate to True against the TEAL logic,\nthen add the compiled TEAL code as its logic signature.\nIt is worth noting that anyone can create and submit the transaction that spends from a contract account as long as they have the compiled TEAL contract to add as a logic signature.\n\nSample teal file\n```teal\n// samplearg.teal\n// This code is meant for learning purposes only\n// It should not be used in production\narg_0\nbtoi\nint 123\n==\n```\n\n```php\n$arguments = [BigInteger::of(123)-\u003etoBytes()];\n\n$result = $this-\u003ealgorand-\u003eapplicationManager()-\u003ecompileTEAL($this-\u003esampleArgsTeal);\n$lsig = LogicSignature::fromProgram($result-\u003eprogram(), $arguments);\n$receiver = 'KTFZ5SQU3AQ6UFYI2QOWF5X5XJTAFRHACWHXAZV6CPLNKS2KSGQWPT4ACE';\n\n$transaction = TransactionBuilder::payment()\n    -\u003esender($lsig-\u003etoAddress())\n    -\u003enote('Contract account')\n    -\u003eamount(100000)\n    -\u003ereceiver(Address::fromAlgorandAddress($receiver))\n    -\u003euseSuggestedParams($this-\u003ealgorand)\n    -\u003ebuild();\n\n// Sign the logic transaction\n$signedTx = $lsig-\u003esignTransaction($transaction);\n\n// Send the transaction\n$pendingTx = $this-\u003ealgorand-\u003esendTransaction($signedTx, true);\n```\n\n### Account Delegation\n\nStateless smart contracts can also be used to delegate signatures, which means that a private key can sign a TEAL program\nand the resulting output can be used as a signature in transactions on behalf of the account associated with the private key.\nThe owner of the delegated account can share this logic signature, allowing anyone to spend funds from his or her account according to the logic within the TEAL program.\n\n```php\n$arguments = [BigInteger::of(123)-\u003etoBytes()];\n\n$result = $this-\u003ealgorand-\u003eapplicationManager()-\u003ecompileTEAL($this-\u003esampleArgsTeal);\n$lsig = LogicSignature::fromProgram($result-\u003eprogram(), $arguments)-\u003esign($this-\u003eaccount);\n$receiver = 'KTFZ5SQU3AQ6UFYI2QOWF5X5XJTAFRHACWHXAZV6CPLNKS2KSGQWPT4ACE';\n\n$transaction = TransactionBuilder::payment()\n    -\u003esender($this-\u003eaccount-\u003egetAddress())\n    -\u003enote('Account delegation')\n    -\u003eamount(100000)\n    -\u003ereceiver(Address::fromAlgorandAddress($receiver))\n    -\u003euseSuggestedParams($this-\u003ealgorand)\n    -\u003ebuild();\n\n// Sign the logic transaction\n$signedTx = $lsig-\u003esignTransaction($transaction);\n\n// Send the transaction\n$pendingTx = $this-\u003ealgorand-\u003esendTransaction($signedTx, true);\n```\n\n## Stateful Smart Contracts\nStateful smart contracts are contracts that live on the chain and are used to keep track of some form of global and/or local state for the contract.\nStateful smart contracts form the backbone of applications that intend to run on the Algorand blockchain. Stateful smart contracts act similar to Algorand ASAs in that they have specific global values and per-user values.\n\n**Create a new application**\n\nBefore creating a stateful smart contract, the code for the ApprovalProgram and the ClearStateProgram program should be written.\nThe creator is the account that is creating the application and this transaction is signed by this account.\nThe approval program and the clear state program should also be provided.\nThe number of global and local byte slices (byte-array value) and integers also needs to be specified.\nThese represent the absolute on-chain amount of space that the smart contract will use.\nOnce set, these values can never be changed.\n\nWhen the smart contract is created the network will return a unique ApplicationID.\nThis ID can then be used to make ApplicationCall transactions to the smart contract.\n\n```php\n$localInts = 1;\n$localBytes = 1;\n$globalInts = 1;\n$globalBytes = 0;\n\n$approvalProgram = $this-\u003ealgorand-\u003eapplicationManager()-\u003ecompileTEAL($this-\u003eapprovalProgramSource);\n$clearProgram = $this-\u003ealgorand-\u003eapplicationManager()-\u003ecompileTEAL($this-\u003eclearProgramSource);\n\n$pendingTx = $this-\u003ealgorand-\u003eapplicationManager()-\u003ecreateApplication(\n    $account,\n    $approvalProgram-\u003eprogram(),\n    $clearProgram-\u003eprogram(),\n    new StateSchema($globalInts, $globalBytes),\n    new StateSchema($localInts, $localBytes),\n    true,\n);\n```\n\nOr you can build the raw transaction using the ```TransactionBuilder::applicationCreate```.\n\n```php\n$localInts = 1;\n$localBytes = 1;\n$globalInts = 1;\n$globalBytes = 0;\n\n$approvalProgram = $this-\u003ealgorand-\u003eapplicationManager()-\u003ecompileTEAL($this-\u003eapprovalProgramSource);\n$clearProgram = $this-\u003ealgorand-\u003eapplicationManager()-\u003ecompileTEAL($this-\u003eclearProgramSource);\n\n$transaction = TransactionBuilder::applicationCreate()\n    -\u003esender($account-\u003egetAddress())\n    -\u003eapprovalProgram($approvalProgram-\u003eprogram())\n    -\u003eclearStateProgram($clearProgram-\u003eprogram())\n    -\u003eglobalStateSchema(new StateSchema($globalInts, $globalBytes))\n    -\u003elocalStateSchema(new StateSchema($localInts, $localBytes))\n    -\u003euseSuggestedParams($this-\u003ealgorand)\n    -\u003ebuild();\n\n$signedTx = $transaction-\u003esign($account);\n\n$pendingTx = $this-\u003ealgorand-\u003esendTransaction($signedTx, true);\n```\n\n**Opt into the Smart Contract**\n\nBefore any account, including the creator of the smart contract, can begin to make Application\nTransaction calls that use local state, it must first opt into the smart contract.\nThis prevents accounts from being spammed with smart contracts.\nTo opt in, an ApplicationCall transaction of type OptIn needs to be signed and submitted by the\naccount desiring to opt into the smart contract.\n\n```php\n$txId = $this-\u003ealgorand-\u003eapplicationManager()-\u003eoptIn($account, BigInteger::of(22266683));\n```\n\nOr you can build the raw transaction using the ```TransactionBuilder::applicationOptIn```.\n\n```php\n$transaction = TransactionBuilder::applicationOptIn()\n    -\u003esender($account-\u003egetAddress())\n    -\u003eapplicationId(BigInteger::of(19964146))\n    -\u003euseSuggestedParams($this-\u003ealgorand)\n    -\u003ebuild();\n\n$signedTx = $transaction-\u003esign($account);\n\n$txId = $this-\u003ealgorand-\u003esendTransaction($signedTx);\n```\n\n**Calling a Stateful Smart Contract**\n\nOnce an account has opted into a stateful smart contract it can begin to make calls to the contract.\nDepending on the individual type of transaction as described in The Lifecycle of a Stateful Smart\nContract, either the ApprovalProgram or the ClearStateProgram will be called.\nGenerally, individual calls will supply application arguments.\nSee [Passing Arguments to a Smart Contract](https://developer.algorand.org/docs/features/asc1/stateful/#passing-arguments-to-stateful-smart-contracts) for details on passing arguments.\n\n```php\n$arguments = AlgorandUtils::parse_application_arguments('str:arg1,int:12');\n$txId = $this-\u003ealgorand-\u003eapplicationManager()-\u003ecall($account, BigInteger::of(22266683), $arguments);\n```\n\nOr you can build the raw transaction using ```TransactionBuilder:applicationCall```.\n\n```php\n$arguments = AlgorandUtils::parse_application_arguments('str:arg1,int:12');\n\n$transaction = TransactionBuilder::applicationCall()\n    -\u003esender($account-\u003egetAddress())\n    -\u003eapplicationId(BigInteger::of(19964146))\n    -\u003earguments($arguments)\n    -\u003eaccounts([$account-\u003egetAddress()])\n    -\u003eforeignApps([22240890])\n    -\u003eforeignAssets([408947])\n    -\u003euseSuggestedParams($this-\u003ealgorand)\n    -\u003ebuild();\n\n$signedTx = $transaction-\u003esign($account);\n\n$txId = $this-\u003ealgorand-\u003esendTransaction($signedTx);\n```\n\n**Update a Stateful Smart Contract**\n\nA stateful smart contract’s programs can be updated at any time.\nThis is done by an ApplicationCall transaction type of UpdateApplication.\nThis operation requires passing the new programs and specifying the application ID.\nThe one caveat to this operation is that global or local state requirements for the smart contract can never be updated.\n\n```php\n$approvalProgram = $this-\u003ealgorand-\u003eapplicationManager()-\u003ecompileTEAL($this-\u003eapprovalProgramSource);\n$clearProgram = $this-\u003ealgorand-\u003eapplicationManager()-\u003ecompileTEAL($this-\u003eclearProgramSource);\n\n$txId = $this-\u003ealgorand-\u003eapplicationManager()-\u003eupdate(\n    $account,\n    BigInteger::of(19964146),\n    $approvalProgram-\u003eprogram(),\n    $clearProgram-\u003eprogram(),\n);\n```\n\nOr you can build the raw transaction using ```TransactionBuilder:applicationUpdate```.\n\n```php\n$approvalProgram = $this-\u003ealgorand-\u003eapplicationManager()-\u003ecompileTEAL($this-\u003eapprovalProgramSource);\n$clearProgram = $this-\u003ealgorand-\u003eapplicationManager()-\u003ecompileTEAL($this-\u003eclearProgramSource);\n\n$transaction = TransactionBuilder::applicationUpdate()\n    -\u003esender($account-\u003egetAddress())\n    -\u003eapplicationId(BigInteger::of(19964146))\n    -\u003eapprovalProgram($approvalProgram-\u003eprogram())\n    -\u003eclearStateProgram($clearProgram-\u003eprogram())\n    -\u003euseSuggestedParams($this-\u003ealgorand)\n    -\u003ebuild();\n\n$signedTx = $transaction-\u003esign($account);\n$txId = $this-\u003ealgorand-\u003esendTransaction($signedTx);\n```\n\n**Delete a Stateful Smart Contract**\n\nTo delete a smart contract, an ApplicationCall transaction of type DeleteApplication must be submitted to the blockchain.\nThe ApprovalProgram handles this transaction type and if the call returns true the application will be deleted.\n\n```php\n$txId = $this-\u003ealgorand-\u003eapplicationManager()-\u003edeleteApplication($account, BigInteger::of(22257782));\n```\n\n**Close out**\n\nThe user may discontinue use of the application by sending a close out transaction. This will remove the local state for this application from the user's account\n\n```php\n$txId = $this-\u003ealgorand-\u003eapplicationManager()-\u003ecloseOut($account, BigInteger::of(19964146));\n```\n\n**Clear state**\n\nThe user may clear the local state for an application at any time, even if the application was deleted by the creator. This method uses the same 3 parameter.\n\n```php\n$txId = $this-\u003ealgorand-\u003eapplicationManager()-\u003eclearState($account, BigInteger::of(19964146));\n```\n\n## Multi Signatures\nMultisignature accounts are a logical representation of an ordered set of addresses with a threshold and version.\nMultisignature accounts can perform the same operations as other accounts, including sending transactions and participating in consensus.\nThe address for a multisignature account is essentially a hash of the ordered list of accounts, the threshold and version values.\nThe threshold determines how many signatures are required to process any transaction from this multisignature account.\n\n**Create a multisignature address**\n\n```php\n$one = Address::fromAlgorandAddress('XMHLMNAVJIMAW2RHJXLXKKK4G3J3U6VONNO3BTAQYVDC3MHTGDP3J5OCRU');\n$two = Address::fromAlgorandAddress('HTNOX33OCQI2JCOLZ2IRM3BC2WZ6JUILSLEORBPFI6W7GU5Q4ZW6LINHLA');\n$three = Address::fromAlgorandAddress('E6JSNTY4PVCY3IRZ6XEDHEO6VIHCQ5KGXCIQKFQCMB2N6HXRY4IB43VSHI');\n\n$publicKeys = array_map(fn (Address $value) =\u003e new Ed25519PublicKey($value-\u003eaddress), [$one, $two, $three]);\n$msigAddr = new MultiSignatureAddress(1, 2, $publicKeys);\n```\n\n**Sign a transaction with a multisignature account**\n\nThis section shows how to create, sign, and send a transaction from a multisig account.\n\n```php\n$account1 = Account::seed($seed1);\n$account2 = Account::seed($seed2);\n$account3 = Account::seed($seed3);\n\n$publicKeys = array_map(fn (Account $value) =\u003e new Ed25519PublicKey($value-\u003egetPublicKey()), [$account1, $account2, $account3]);\n$msigAddr = new MultiSignatureAddress(1, 2, $publicKeys);\n\n$transaction = TransactionBuilder::payment()\n    -\u003esender($msigAddr-\u003etoAddress())\n    -\u003enote('MSA')\n    -\u003eamount(Algo::fromMicroAlgos(1000000))\n    -\u003ereceiver($account3-\u003egetAddress())\n    -\u003euseSuggestedParams($this-\u003ealgorand)\n    -\u003ebuild();\n\n$signedTx = $msigAddr-\u003esign($account1, $transaction);\n$completeTx = $msigAddr-\u003eappend($account2, $signedTx);\n$completeTx2 = $msigAddr-\u003eappend($account3, $completeTx);\n\n$txId = $this-\u003ealgorand-\u003esendTransaction($completeTx2);\n```\n\n## Key Management Daemon\n\nThe Key Management Daemon (kmd) is a low level wallet and key management tool. It works in conjunction with algod and goal to keep secrets safe.\nkmd tries to ensure that secret keys never touch the disk unencrypted.\n\n* kmd has a data directory separate from algod's data directory. By default, however, the kmd data directory is in the kmd subdirectory of algod's data directory.\n* kmd starts an HTTP API server on localhost:7833 by default.\n* You talk to the HTTP API by sending json-serialized request structs from the kmdapi package.\n\nNote: If you are using a third-party API service, this process likely will not be available to you.\n\n```php\n$request = new CreateWalletRequest([\n   \"wallet_name\" =\u003e \"test1\",\n   \"wallet_password\" =\u003e \"test\",\n   \"wallet_driver_name\" =\u003e \"sqlite\",\n]);\n\ntry {\n    $result = $algorand-\u003ekmd()-\u003ecreateWallet($request);\n    print_r($result);\n} catch (Exception $e) {\n    echo 'Exception when calling DefaultApi-\u003ecreateWallet: ', $e-\u003egetMessage(), PHP_EOL;\n}\n```\n\nCheck out the [Algorand Developer documentation ](https://developer.algorand.org/docs/features/accounts/create/#wallet-derived-kmd) to learn more about the Key Management Daemon.\n\n## Indexer\nAlgorand provides a standalone daemon algorand-indexer that reads committed blocks from the Algorand blockchain and\nmaintains a local database of transactions and accounts that are searchable and indexed.\n\nThe PHP SDK makes it really easy to search the ledger in a fluent api and enables application developers to perform rich and efficient queries on accounts,\ntransactions, assets, and so forth.\n\nAt the moment we support queries on transactions, assets and accounts.\n\n### Transactions\nAllow searching all transactions that have occurred on the blockchain.\n\n```php\n$algorand-\u003eindexer()\n    -\u003etransactions()\n    -\u003ewhereCurrencyIsLessThan(Algo::toMicroAlgos(1000))\n    -\u003ewhereCurrencyIsGreaterThan(Algo::toMicroAlgos(500))\n    -\u003ewhereAssetId(14502)\n    -\u003ewhereNotePrefix('PHP')\n    -\u003ewhereTransactionType(TransactionType::PAYMENT())\n    -\u003esearch();\n```\n\n### Assets\nAllow searching all assets that are created on the blockchain.\n\n```php\n$algorand-\u003eindexer()\n    -\u003eassets()\n    -\u003ewhereUnitName('PHP')\n    -\u003ewhereAssetName('PHPCoin')\n    -\u003ewhereCurrencyIsLessThan(Algo::toMicroAlgos(1000))\n    -\u003ewhereCurrencyIsGreaterThan(Algo::toMicroAlgos(500))\n    -\u003ewhereAssetId(14502)\n    -\u003esearch();\n```\n\n### Accounts\nAllow searching all accounts that are created on the blockchain.\n\n```php\nAlgorand::indexer()\n    -\u003eaccounts()\n    -\u003ewhereAssetId(15205)\n    -\u003ewhereAuthAddress('RQM43TQH4CHTOXKPLDWVH4FUZQVOWYHRXATHJSQLF7GN6CFFLC35FLNYHM')\n    -\u003elimit(5)\n    -\u003esearch();\n```\n\n### Applications\nAllow searching all applications on the blockchain.\n\n```php\nAlgorand::indexer()\n    -\u003eapplications()\n    -\u003ewhereApplicationId(19964146)\n    -\u003elimit(5)\n    -\u003esearch();\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing \u0026 Pull Requests\nFeel free to send pull requests.\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Questions?\nDo you have any questions, join us at the official Algorand [Discord](https://discord.com/invite/84AActu3at)!\n\n## Credits\n\n- [Tomas Verhelst](https://github.com/rootsoft)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n[packagist-shield]: https://img.shields.io/packagist/v/rootsoft/algorand-php.svg?style=for-the-badge\n[packagist-url]: https://packagist.org/packages/rootsoft/algorand-php\n[downloads-shield]: https://img.shields.io/packagist/dt/rootsoft/algorand-php.svg?style=for-the-badge\n[downloads-url]: https://packagist.org/packages/rootsoft/algorand-php\n[issues-shield]: https://img.shields.io/github/issues/rootsoft/algorand-php.svg?style=for-the-badge\n[issues-url]: https://github.com/rootsoft/algorand-php/issues\n[license-shield]: https://img.shields.io/github/license/rootsoft/algorand-php.svg?style=for-the-badge\n[license-url]: https://github.com/rootsoft/algorand-php/blob/master/LICENSE.txt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frootsoft%2Falgorand-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frootsoft%2Falgorand-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frootsoft%2Falgorand-php/lists"}