<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lit Protocol</title>
    <description>The latest articles on DEV Community by Lit Protocol (@litprotocol).</description>
    <link>https://dev.to/litprotocol</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4248484%2F500af616-bf3c-4cd9-b4d8-340d826b7ade.png</url>
      <title>DEV Community: Lit Protocol</title>
      <link>https://dev.to/litprotocol</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/litprotocol"/>
    <language>en</language>
    <item>
      <title>How to build a crypto trading bot that signs its own transactions</title>
      <dc:creator>Lit Protocol</dc:creator>
      <pubDate>Mon, 16 Nov 2026 21:31:41 +0000</pubDate>
      <link>https://dev.to/litprotocol/how-to-build-a-crypto-trading-bot-that-signs-its-own-transactions-2ocj</link>
      <guid>https://dev.to/litprotocol/how-to-build-a-crypto-trading-bot-that-signs-its-own-transactions-2ocj</guid>
      <description>&lt;p&gt;A trading bot has three parts. There is code that decides when to trade, code that builds the transaction, and a key that signs it. The usual setup keeps the key in an environment variable on the same server as the strategy, so a bug or a break-in can sign anything. On Lit Protocol you can run the whole bot as a Lit Action and have Lit Triggers run it on a schedule. The action checks the price, applies your limits, and signs with a key that only that exact code can use. You do not run a server, and nobody holds the key.&lt;/p&gt;

&lt;p&gt;I will build a small take-profit bot. Every hour it checks the price of ETH, and if ETH is above $4,000 it sells 0.01 ETH for USDC on Base.&lt;/p&gt;

&lt;h2&gt;
  
  
  The bot
&lt;/h2&gt;

&lt;p&gt;A Lit Action is a JavaScript function that runs inside a secure enclave. Every action has its own wallet, and the key for that wallet is derived from a hash of the action's code. If you change one character of the code, you get a different wallet. So the rules in this file are tied to the money in the wallet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// bot.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;OWNER&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"0xYourOwnWallet..."&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;          &lt;span class="c1"&gt;// the only address it will withdraw to&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;USDC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// USDC on Base&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;ROUTER&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"0xYourAggregatorRouter..."&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// the only contract it will call&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;SELL_ABOVE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                      &lt;span class="c1"&gt;// USD per ETH&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;SELL_ETH&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"0.01"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                      &lt;span class="c1"&gt;// the most it sells in one run&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;provider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;StaticJsonRpcProvider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://mainnet.base.org"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Wallet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;Lit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Actions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getLitActionPrivateKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;addressOnly&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;address&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;address&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;withdraw&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;usdc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Contract&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;USDC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"function balanceOf(address) view returns (uint256)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"function transfer(address,uint256) returns (bool)"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;usdcBalance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;usdc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;balanceOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wallet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;address&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;usdcBalance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;gt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;usdc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;OWNER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;usdcBalance&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;reserve&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parseEther&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"0.0001"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// left behind to pay for the ETH transfer&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;balance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getBalance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lte&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reserve&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;withdrew&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;usdc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;usdcBalance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendTransaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;OWNER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reserve&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;withdrew&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;usdc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;usdcBalance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hash&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;prices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://api.coingecko.com/api/v3/simple/price?ids=ethereum&amp;amp;vs_currencies=usd"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ethereum&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;usd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;SELL_ABOVE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;traded&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;sellWei&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parseEther&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;SELL_ETH&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;quote&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`https://quotes.example.com/swap?chain=base&amp;amp;sell=ETH&amp;amp;buy=USDC&amp;amp;amount=${sellWei}&amp;amp;taker=${wallet.address}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="no"&gt;ROUTER&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;traded&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"unexpected contract"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;BigNumber&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;gt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sellWei&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;traded&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"quote sells too much"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;minUsdc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;SELL_ETH&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.99&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;1e6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// at least 99% of the price it just read&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;buyAmount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;minUsdc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;traded&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"quote too low"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendTransaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;traded&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hash&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;quotes.example.com&lt;/code&gt; stands in for whichever DEX aggregator you use. Most of them return the router address, the calldata, the value to send, and the amount you will get back, which is what the bot checks.&lt;/p&gt;

&lt;p&gt;The bot does trust the aggregator's calldata. It checks which contract it calls and how much ETH it sends, but it does not decode the swap itself, so a compromised aggregator could send the USDC somewhere else. For real money, decode the router call inside the action and check that the recipient is the bot's own address and that the minimum output is at least &lt;code&gt;minUsdc&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Notice that the settings are constants at the top of the file. Anyone who has the API key that runs this action can call it with whatever parameters they want. So the owner, the router, the price, and the size are written into the code, where a caller cannot change them. The only two parameters the bot reads are &lt;code&gt;addressOnly&lt;/code&gt; and &lt;code&gt;withdraw&lt;/code&gt;, and neither one can send money anywhere except &lt;code&gt;OWNER&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A caller with the key can also run the trading part whenever they like, not only once an hour. So &lt;code&gt;SELL_ETH&lt;/code&gt; limits each run, not each hour. Keep the usage key as private as you would keep a private key, and only put in the wallet what you are willing to have the bot sell.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting it up
&lt;/h2&gt;

&lt;p&gt;Go to the &lt;a href="https://dashboard.chipotle.litprotocol.com/dapps/dashboard/" rel="noopener noreferrer"&gt;Lit dashboard&lt;/a&gt; and click &lt;strong&gt;Create an account&lt;/strong&gt;. Choose &lt;strong&gt;API key&lt;/strong&gt;, fill in your email and an account name, and copy the account API key it gives you. Add some credit with &lt;strong&gt;Add Funds&lt;/strong&gt;. Then get the action's content hash, put it in a group, and make an API key that can only run that group.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;LIT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https://api.chipotle.litprotocol.com/core/v1
&lt;span class="nv"&gt;CID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;jq -Rs . bot.js &lt;span class="o"&gt;|&lt;/span&gt; curl -s -X POST &lt;span class="s2"&gt;"$LIT/get_lit_action_ipfs_id"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; -d @- &lt;span class="o"&gt;|&lt;/span&gt; jq -r .&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="nv"&gt;GROUP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;curl -s -X POST &lt;span class="s2"&gt;"$LIT/add_group"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"group_name":"bot","group_description":"","pkp_ids_permitted":[],"cid_hashes_permitted":[]}'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; jq -r .group_id&lt;span class="o"&gt;)&lt;/span&gt;
curl -s -X POST &lt;span class="s2"&gt;"$LIT/add_action_to_group"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s2"&gt;"{\"group_id\":$GROUP,\"action_ipfs_cid\":\"$CID\"}"&lt;/span&gt;
&lt;span class="nv"&gt;USAGE_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;curl -s -X POST &lt;span class="s2"&gt;"$LIT/add_usage_api_key"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"name":"bot","description":"","can_create_groups":false,"can_delete_groups":false,"can_create_pkps":false,
       "manage_ipfs_ids_in_groups":[],"add_pkp_to_groups":[],"remove_pkp_from_groups":[],"execute_in_groups":['&lt;/span&gt;&lt;span class="s2"&gt;"$GROUP"&lt;/span&gt;&lt;span class="s1"&gt;']}'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; jq -r .usage_api_key&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ask the bot for its wallet address, and send it the ETH you want it to trade.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jq -n --rawfile code bot.js &lt;span class="s1"&gt;'{code: $code, js_params: {addressOnly: true}}'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; curl -s -X POST &lt;span class="s2"&gt;"$LIT/lit_action"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $USAGE_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; -d @-
&lt;span class="c"&gt;# {"response":{"address":"0x..."},...}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;New permissions can take up to 30 seconds to start working, so keep retrying this call for a minute if it is refused.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running it every hour
&lt;/h2&gt;

&lt;p&gt;Lit Triggers runs an action on a schedule, when a webhook arrives, or when an event happens on-chain. You authorize it once from your browser. The pairing steps are in the Lit Triggers agent guide at &lt;a href="https://triggers.litprotocol.com/SKILL.md" rel="noopener noreferrer"&gt;triggers.litprotocol.com/SKILL.md&lt;/a&gt;, and you can hand that file to a coding agent to walk through them with you. At the end your token is authorized. Then create a schedule trigger with the bot's code and the API key from the last step.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jq -n --rawfile code bot.js --arg key &lt;span class="s2"&gt;"$USAGE_KEY"&lt;/span&gt; \
  &lt;span class="s1"&gt;'{name: "eth-take-profit", kind: "schedule", action_code: $code, usage_api_key: $key, config: {cron: "0 * * * *"}}'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; curl -s -X POST https://triggers.litprotocol.com/api/triggers \
      -H &lt;span class="s2"&gt;"authorization: Bearer $TRIGGERS_TOKEN"&lt;/span&gt; -H &lt;span class="s2"&gt;"content-type: application/json"&lt;/span&gt; -d @-
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each run is recorded with what the bot returned, so you can see every price it read and every trade it made.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s -H &lt;span class="s2"&gt;"authorization: Bearer $TRIGGERS_TOKEN"&lt;/span&gt; &lt;span class="s2"&gt;"https://triggers.litprotocol.com/api/triggers/&amp;lt;id&amp;gt;/runs?limit=20"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Changing the bot
&lt;/h2&gt;

&lt;p&gt;Because the wallet comes from the code, a new version of the bot has a new wallet. Before you switch, call the old version with &lt;code&gt;withdraw&lt;/code&gt; set to true, and its ETH and USDC go back to &lt;code&gt;OWNER&lt;/code&gt;. Then fund the new version's address. If you would rather keep one address across versions, create a wallet with the API and use &lt;code&gt;Lit.Actions.getPrivateKey&lt;/code&gt; instead. That wallet stays the same when you add a new version of the code to its group.&lt;/p&gt;

&lt;p&gt;For real money, read the price from more than one source and compare them before you trade. The &lt;a href="https://developer.litprotocol.com/lit-actions/examples" rel="noopener noreferrer"&gt;examples page&lt;/a&gt; has a price check that uses several sources.&lt;/p&gt;

&lt;h2&gt;
  
  
  When this is the wrong setup
&lt;/h2&gt;

&lt;p&gt;Lit Triggers can run a bot as often as every 30 seconds. That works for take-profit, rebalancing, and buying on a schedule. It is too slow for market making or arbitrage, where you sign many times a second from your own server. For that kind of bot, keep the strategy on your server and have it call a Lit Action that checks each trade before signing. The post on &lt;a href="https://spark.litprotocol.com/backend-signing-without-exposing-keys/" rel="noopener noreferrer"&gt;signing from your backend without exposing the private key&lt;/a&gt; shows how.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get started
&lt;/h2&gt;

&lt;p&gt;To create an account, go to the &lt;a href="https://dashboard.chipotle.litprotocol.com/dapps/dashboard/" rel="noopener noreferrer"&gt;Lit dashboard&lt;/a&gt; and click &lt;strong&gt;Create an account&lt;/strong&gt;. Lit Triggers is documented at &lt;a href="https://developer.litprotocol.com/lit-triggers/index" rel="noopener noreferrer"&gt;developer.litprotocol.com/lit-triggers&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>web3</category>
      <category>blockchain</category>
      <category>javascript</category>
      <category>security</category>
    </item>
    <item>
      <title>How to use AI on sensitive company data without the vendor seeing it</title>
      <dc:creator>Lit Protocol</dc:creator>
      <pubDate>Mon, 16 Nov 2026 21:26:41 +0000</pubDate>
      <link>https://dev.to/litprotocol/how-to-use-ai-on-sensitive-company-data-without-the-vendor-seeing-it-461b</link>
      <guid>https://dev.to/litprotocol/how-to-use-ai-on-sensitive-company-data-without-the-vendor-seeing-it-461b</guid>
      <description>&lt;p&gt;To use AI on sensitive company data without the vendor seeing it, run the vendor's application inside confidential hardware, allow it to reach only the services you approve, and check what is running before you send it anything. Lit sets this up on Google Cloud Confidential VMs, which use Intel TDX to keep the machine's memory encrypted while it works. The application runs as a Docker container. The list of services it can reach is part of the deployment, and any change to the code or that list waits for your organization to approve it on-chain. Before your team connects, a hardware attestation shows exactly which release is running.&lt;/p&gt;

&lt;p&gt;This is for two kinds of teams. The first is a company that wants to use an AI product on legal, financial, health, or customer data and cannot accept "trust us" from the vendor. The second is an AI vendor whose customers keep asking whether the vendor can see their data, and who wants to answer with something the customer can check.&lt;/p&gt;

&lt;h2&gt;
  
  
  The usual options
&lt;/h2&gt;

&lt;p&gt;The first option is to trust the vendor's policy. Many AI vendors promise not to train on your data or keep it. That is a policy, and the vendor can change it. A breach at the vendor would expose the data anyway.&lt;/p&gt;

&lt;p&gt;The second is to self-host an open model on your own servers. Nobody outside your company sees the data, but you have to run the GPUs and the application yourself, and you may give up the vendor product your team wanted.&lt;/p&gt;

&lt;p&gt;The third is to run the vendor's product in confidential hardware. The vendor's software does the work. The hardware keeps the cloud operator and the host from reading the data while it is in use, and network rules decide where the software can send it. This is what Lit sets up.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;p&gt;The vendor's application runs as a Docker container in a Confidential VM on Google Cloud. The processor encrypts the machine's memory, so the host operating system and Google's operators cannot read it. For models that need a GPU, Google's A3 machines with NVIDIA H100 GPUs extend confidential computing to the GPU.&lt;/p&gt;

&lt;p&gt;Each deployment lists the exact hostnames the container may reach, on port 443 only, with no wildcards. A proxy inside the confidential machine enforces that list. If the list is empty, the application has no network route out at all and only answers requests on its own ports. The list is part of the deployment's measured configuration, so the vendor cannot quietly add a destination. Adding one is a new release, and it does not run until your organization approves it.&lt;/p&gt;

&lt;p&gt;Here is a typical example. An enterprise search app runs in the confidential machine with your documents. Its only allowed destination is the model provider's API. Your team searches and gets cited answers. The model API is the only outside service the app can send your data to, and the vendor cannot add another one without your approval.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you can check
&lt;/h2&gt;

&lt;p&gt;Before your team connects, you can check two things. The attestation is signed by genuine Intel hardware, and the configuration it records, including the Docker image and the network list, matches a release on your deployment's approved list on Base, where anyone can read it. The first release is recorded when the deployment is created, and every change after that needs your organization's approval. Lit gives your team a command that checks all of this using only the attestation, the deployment's address, and a public Base RPC endpoint.&lt;/p&gt;

&lt;h2&gt;
  
  
  Decisions to make with Lit
&lt;/h2&gt;

&lt;p&gt;A few choices shape how private the setup is, and Lit works through them with you.&lt;/p&gt;

&lt;p&gt;The first is where the model runs. If the application calls an outside model API, that provider sees what the application sends it. Many teams accept that, because it is the only outside service the application can reach. If even the model provider should not see the data, the model runs inside the confidential machine too, usually as an open model on a confidential GPU.&lt;/p&gt;

&lt;p&gt;The second is what the application keeps and sends. The attestation proves which software is running, so review that software and its network list together. Lit can help you read both.&lt;/p&gt;

&lt;p&gt;The third is the model weights. If the application downloads weights at startup, they should be checked against the exact version you expect.&lt;/p&gt;

&lt;h2&gt;
  
  
  Working with Lit
&lt;/h2&gt;

&lt;p&gt;Lit sets up each deployment with your team. Send us the application or the vendor's container, describe the data it will handle and the services it needs to reach, and tell us your performance goals. We will come back with a hardware plan on Google Cloud, a network list for you to approve, and the approval setup for your organization. Then we deploy it and walk your team through the check. To start, use the &lt;a href="https://docs.google.com/forms/d/e/1FAIpQLSeIqxiiMLBgk-igTDU665Yx3UZsGrP_PgLUy9sh7sUx1mYyGg/viewform" rel="noopener noreferrer"&gt;Lit AI contact form&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>security</category>
      <category>ai</category>
      <category>privacy</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Where to store private keys in your app</title>
      <dc:creator>Lit Protocol</dc:creator>
      <pubDate>Mon, 16 Nov 2026 21:21:40 +0000</pubDate>
      <link>https://dev.to/litprotocol/where-to-store-private-keys-in-your-app-14fo</link>
      <guid>https://dev.to/litprotocol/where-to-store-private-keys-in-your-app-14fo</guid>
      <description>&lt;p&gt;The safest place for a private key is somewhere your app can ask for a signature without ever reading the key. On a phone, that means the iOS Keychain or the Android Keystore. On a server, it means a key management service, a hardware security module, or a hosted signer. For a crypto wallet that your app controls, Lit Protocol keeps the key inside a secure enclave and runs your signing rule in the same enclave. Your server holds an API key that can ask for signatures, and that is all it holds.&lt;/p&gt;

&lt;p&gt;I will go through the places people usually put keys, and then show how the Lit version works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Places the key should not go
&lt;/h2&gt;

&lt;p&gt;Do not put a private key in your source code, even in a private repo. Git history keeps it after you delete it. Do not put it in a frontend bundle or in browser storage like localStorage, because anyone who opens your app can read it. Be careful with environment variables too. They are better than source code, but they get baked into container images, printed in crash reports, and read by other processes running as the same user. And check your logs. A key that shows up once in a debug line is a key you have to rotate.&lt;/p&gt;

&lt;h2&gt;
  
  
  On a user's phone
&lt;/h2&gt;

&lt;p&gt;If the key belongs to the user, keep it on their device. The iOS Keychain and the Android Keystore are backed by secure hardware on most devices, and apps cannot read each other's entries. One detail matters for crypto. The secure hardware on phones signs with a different curve than Ethereum and Bitcoin use, so a wallet app usually generates the wallet key, encrypts it with a key held by that hardware, and stores the encrypted copy. The wallet key only exists in memory while it is signing.&lt;/p&gt;

&lt;h2&gt;
  
  
  On a server
&lt;/h2&gt;

&lt;p&gt;For a key your server uses, the standard answer is a key management service like AWS KMS or Google Cloud KMS. Both can generate a secp256k1 key, which is the kind Ethereum and Bitcoin use. The key stays in the provider's hardware. Your server sends a hash and gets back a signature. This is a big improvement over an environment variable, because nobody can copy the key.&lt;/p&gt;

&lt;p&gt;There is one limit worth knowing about. A KMS signs whatever hash it is given. It does not know what a transaction is, so it cannot check the amount or the recipient. The only thing between a compromised server and a signature is the IAM policy that lets your server call the KMS. The post on &lt;a href="https://spark.litprotocol.com/backend-signing-without-exposing-keys/" rel="noopener noreferrer"&gt;signing from your backend without exposing the private key&lt;/a&gt; compares a KMS with the other places a server's key can live.&lt;/p&gt;

&lt;h2&gt;
  
  
  A signer that checks each transaction
&lt;/h2&gt;

&lt;p&gt;On Lit, the key lives in an enclave, and so does a JavaScript function that decides whether to sign. That function is called a Lit Action. This one only sends USDC on Base to addresses on an allowlist, and never more than 1,000 USDC at a time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// payout.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;USDC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;ALLOWED&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"0xVendorOne..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"0xVendorTwo..."&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;MAX&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1000_000000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// 1,000 USDC, which has 6 decimals&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;pkpId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="no"&gt;ALLOWED&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;sent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"recipient not on the allowlist"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;MAX&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;sent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"over the limit"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;provider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;StaticJsonRpcProvider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://mainnet.base.org"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Wallet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;Lit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Actions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getPrivateKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;pkpId&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;usdc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Contract&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;USDC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"function transfer(address,uint256) returns (bool)"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;usdc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;sent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hash&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The allowlist and the limit are part of the code. Lit knows the action by its content hash, so if someone changes the allowlist, it becomes a different action with a different hash, and your server's key is not allowed to run it.&lt;/p&gt;

&lt;p&gt;Your server calls it like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jq -n --rawfile code payout.js &lt;span class="s1"&gt;'{code: $code, js_params: {pkpId: "0xYourWallet", to: "0xVendorOne...", amount: "250000000"}}'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; curl -s -X POST https://api.chipotle.litprotocol.com/core/v1/lit_action \
      -H &lt;span class="s2"&gt;"X-Api-Key: $USAGE_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; -d @-
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;USAGE_KEY&lt;/code&gt; is an API key that can run actions in one group and do nothing else. It cannot read the private key, add a new action, or change the group. If someone steals it, they can send payments of up to 1,000 USDC each to your vendors until the wallet is empty, and spend its ETH on gas while they do it. They cannot do anything else. The wallet also needs a little ETH on Base to pay for gas. The setup calls for the wallet, the group, and the key are in the &lt;a href="https://developer.litprotocol.com/management/api_direct" rel="noopener noreferrer"&gt;API reference&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  If the key has to be in memory
&lt;/h2&gt;

&lt;p&gt;Sometimes a library needs the raw key and you cannot avoid it. In that case, keep the key in a secrets manager and load it when the process starts, instead of keeping it in a file or an image. Run the signing code as its own small service, so the rest of your app never has the key in memory. Keep only a working balance in that wallet and top it up from a wallet that is kept offline. And write down how you would rotate the key before you need to.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get started
&lt;/h2&gt;

&lt;p&gt;To create an account, go to the &lt;a href="https://dashboard.chipotle.litprotocol.com/dapps/dashboard/" rel="noopener noreferrer"&gt;Lit dashboard&lt;/a&gt; and click &lt;strong&gt;Create an account&lt;/strong&gt;. The quickstart is at &lt;a href="https://developer.litprotocol.com/quickstart" rel="noopener noreferrer"&gt;developer.litprotocol.com/quickstart&lt;/a&gt;, and the two kinds of API keys are explained at &lt;a href="https://developer.litprotocol.com/management/api_keys" rel="noopener noreferrer"&gt;developer.litprotocol.com/management/api_keys&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>web3</category>
      <category>blockchain</category>
      <category>javascript</category>
      <category>security</category>
    </item>
    <item>
      <title>How to program a crypto wallet</title>
      <dc:creator>Lit Protocol</dc:creator>
      <pubDate>Mon, 16 Nov 2026 21:16:40 +0000</pubDate>
      <link>https://dev.to/litprotocol/how-to-program-a-crypto-wallet-3l2l</link>
      <guid>https://dev.to/litprotocol/how-to-program-a-crypto-wallet-3l2l</guid>
      <description>&lt;p&gt;A crypto wallet is a private key and some code that uses the key to sign transactions. You can write one in a few lines of JavaScript with a library like ethers or viem. Writing the code is the easy part. The harder part is deciding where the private key lives once the wallet holds real money. On Lit Protocol you can create a wallet with one API call. The key is generated inside a secure enclave, only the code you permit can use it, and your app never holds the key.&lt;/p&gt;

&lt;p&gt;I will start with a version you can run on your laptop, and then show how to move the key out of your app.&lt;/p&gt;

&lt;h2&gt;
  
  
  A wallet in a few lines of JavaScript
&lt;/h2&gt;

&lt;p&gt;This uses ethers v6. It creates a new key and prints the address.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Wallet&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"ethers"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Wallet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createRandom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wallet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;address&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;    &lt;span class="c1"&gt;// give this out to receive funds&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wallet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;privateKey&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// whoever has this controls the wallet&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the address has some ETH on it, you can send a transaction from it. This sends 0.001 ETH on Base.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Wallet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;JsonRpcProvider&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;parseEther&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"ethers"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;provider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;JsonRpcProvider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://mainnet.base.org"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Wallet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;PRIVATE_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendTransaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0xRecipient..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;parseEther&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"0.001"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is a working wallet. Every transaction goes through the same three steps. You build it, you sign it with the private key, and you send it to the network through an RPC node. viem does the same thing for EVM chains, &lt;a class="mentioned-user" href="https://dev.to/solana"&gt;@solana&lt;/a&gt;/web3.js does it for Solana, and bitcoinjs-lib builds and signs Bitcoin transactions.&lt;/p&gt;

&lt;h2&gt;
  
  
  The private key is the hard part
&lt;/h2&gt;

&lt;p&gt;Look at where the key went in the second example. It is in an environment variable, and that is where most people put it. It works fine for testing. For a real app it has two problems. Anything that can read your server's memory or environment can copy the key. And nothing stands between your code and the signature, so a bug in your code signs whatever the bug produces.&lt;/p&gt;

&lt;p&gt;The right place for the key depends on who owns the wallet. If you are building a wallet app where people hold their own funds, the key should stay on the user's device, protected by the phone's secure storage or a hardware wallet. If your app controls the wallet itself, like a payout service, a trading bot, or an AI agent, the key should live in a signer that your app calls over an API.&lt;/p&gt;

&lt;h2&gt;
  
  
  The same wallet on Lit
&lt;/h2&gt;

&lt;p&gt;Go to the &lt;a href="https://dashboard.chipotle.litprotocol.com/dapps/dashboard/" rel="noopener noreferrer"&gt;Lit dashboard&lt;/a&gt; and click &lt;strong&gt;Create an account&lt;/strong&gt;. Choose &lt;strong&gt;API key&lt;/strong&gt;, fill in your email and an account name, and copy the account API key it gives you. Add at least $5 of credit with &lt;strong&gt;Add Funds&lt;/strong&gt;, and then create a wallet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;LIT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https://api.chipotle.litprotocol.com/core/v1
&lt;span class="nv"&gt;WALLET&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;curl -s -X POST &lt;span class="s2"&gt;"$LIT/create_wallet"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; jq -r .wallet_address&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$WALLET&lt;/span&gt;   &lt;span class="c"&gt;# 0x...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The key for that address was created inside the enclave. Only actions that you put in a group with the wallet can use it, and it only leaves the enclave if one of those actions sends it out. To use it, you write a Lit Action. A Lit Action is a JavaScript function that runs in the enclave with the key. This one sends ETH on Base, and it refuses to send more than 0.05 ETH at a time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// send.js&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;pkpId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amountEth&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amountEth&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.05&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;sent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"over the 0.05 ETH limit"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;provider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;StaticJsonRpcProvider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://mainnet.base.org"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Wallet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;Lit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Actions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getPrivateKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;pkpId&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendTransaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parseEther&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amountEth&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;sent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hash&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code inside an action uses ethers v5, so the syntax is a little different from the laptop version.&lt;/p&gt;

&lt;p&gt;Lit knows an action by its content hash. You ask the API for the hash, put the action and the wallet in a group, and make an API key for your app that can only run actions in that group. The post on &lt;a href="https://spark.litprotocol.com/wallet-api-for-developers/" rel="noopener noreferrer"&gt;adding wallets to your app with an API&lt;/a&gt; explains each of these calls.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;CID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;jq -Rs . send.js &lt;span class="o"&gt;|&lt;/span&gt; curl -s -X POST &lt;span class="s2"&gt;"$LIT/get_lit_action_ipfs_id"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; -d @- &lt;span class="o"&gt;|&lt;/span&gt; jq -r .&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="nv"&gt;GROUP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;curl -s -X POST &lt;span class="s2"&gt;"$LIT/add_group"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"group_name":"sender","group_description":"","pkp_ids_permitted":[],"cid_hashes_permitted":[]}'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; jq -r .group_id&lt;span class="o"&gt;)&lt;/span&gt;
curl -s -X POST &lt;span class="s2"&gt;"$LIT/add_action_to_group"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s2"&gt;"{\"group_id\":$GROUP,\"action_ipfs_cid\":\"$CID\"}"&lt;/span&gt;
curl -s -X POST &lt;span class="s2"&gt;"$LIT/add_pkp_to_group"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s2"&gt;"{\"group_id\":$GROUP,\"pkp_id\":\"$WALLET\"}"&lt;/span&gt;

&lt;span class="nv"&gt;USAGE_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;curl -s -X POST &lt;span class="s2"&gt;"$LIT/add_usage_api_key"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"name":"my-app","description":"","can_create_groups":false,"can_delete_groups":false,"can_create_pkps":false,
       "manage_ipfs_ids_in_groups":[],"add_pkp_to_groups":[],"remove_pkp_from_groups":[],"execute_in_groups":['&lt;/span&gt;&lt;span class="s2"&gt;"$GROUP"&lt;/span&gt;&lt;span class="s1"&gt;']}'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; jq -r .usage_api_key&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Send some ETH on Base to the wallet address so it can pay for gas. Then your app sends a transaction by posting the action's code with its parameters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jq -n --rawfile code send.js --arg wallet &lt;span class="s2"&gt;"$WALLET"&lt;/span&gt; &lt;span class="s1"&gt;'{code: $code, js_params: {pkpId: $wallet, to: "0xRecipient...", amountEth: "0.001"}}'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; curl -s -X POST &lt;span class="s2"&gt;"$LIT/lit_action"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $USAGE_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; -d @-
&lt;span class="c"&gt;# {"response":{"sent":true,"hash":"0x..."},"logs":"","has_error":false}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The enclave hashes the code and checks that your key is allowed to run that hash. When the action asks for the private key, the enclave checks that the wallet is in a group with that hash. New permissions can take up to 30 seconds to start working, so keep retrying the first call for a minute if it is refused.&lt;/p&gt;

&lt;p&gt;Your app now holds a key that can run send.js and nothing else. It cannot read the private key, it cannot raise the limit, and it cannot sign with different code. If you want a different limit later, you change the code, which gives it a new hash. You add the new hash with &lt;code&gt;add_action_to_group&lt;/code&gt; and remove the old one with &lt;code&gt;remove_action_from_group&lt;/code&gt;. That call takes the action's hashed ID from &lt;code&gt;list_actions&lt;/code&gt;, not the CID. A removal can take up to five minutes to take effect everywhere. The wallet address stays the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which approach to use
&lt;/h2&gt;

&lt;p&gt;If you are learning, or working on a testnet, the laptop version is fine. If your users hold their own funds, keep their keys on their devices or use an embedded wallet product with a login flow. If your app controls the wallet and you want the rules for signing to live next to the key, that is what Lit is for.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get started
&lt;/h2&gt;

&lt;p&gt;To create an account, go to the &lt;a href="https://dashboard.chipotle.litprotocol.com/dapps/dashboard/" rel="noopener noreferrer"&gt;Lit dashboard&lt;/a&gt; and click &lt;strong&gt;Create an account&lt;/strong&gt;. The quickstart is at &lt;a href="https://developer.litprotocol.com/quickstart" rel="noopener noreferrer"&gt;developer.litprotocol.com/quickstart&lt;/a&gt;, and there are more actions you can copy at &lt;a href="https://developer.litprotocol.com/lit-actions/examples" rel="noopener noreferrer"&gt;developer.litprotocol.com/lit-actions/examples&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>web3</category>
      <category>blockchain</category>
      <category>javascript</category>
      <category>security</category>
    </item>
    <item>
      <title>How to verify the code that signs your transactions</title>
      <dc:creator>Lit Protocol</dc:creator>
      <pubDate>Mon, 16 Nov 2026 21:11:39 +0000</pubDate>
      <link>https://dev.to/litprotocol/how-to-verify-the-code-that-signs-your-transactions-1l19</link>
      <guid>https://dev.to/litprotocol/how-to-verify-the-code-that-signs-your-transactions-1l19</guid>
      <description>&lt;p&gt;You can verify a hosted signer with four checks. Get the enclave's attestation and verify it against the hardware vendor. Match the attested measurement to a public build. Confirm that your TLS connection ends inside that enclave. Then check who approved that build to hold keys. On Lit Protocol you can run all four yourself, and the last one is a smart contract on Base that anyone can read.&lt;/p&gt;

&lt;p&gt;I want to be clear about what an attestation is, because the word gets used loosely. An attestation is a statement signed by the chip maker's key. It says that a specific piece of software, with a specific measurement, is running inside a real enclave. That is useful, but by itself it only proves a hash. The other three checks are what connect that hash to code you can read and to a decision someone made to trust it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check 1: verify the attestation
&lt;/h2&gt;

&lt;p&gt;Lit's API serves an Intel TDX quote. You verify it with the open-source dstack verifier. The exact endpoint and verifier image are in our &lt;a href="https://developer.litprotocol.com/architecture/verification/full-verification" rel="noopener noreferrer"&gt;verification guide&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s &lt;span class="s2"&gt;"$LIT_ATTESTATION_URL"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; quote.json
docker run --rm -v &lt;span class="s2"&gt;"$PWD/quote.json:/quote.json"&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;dstack-verifier&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; verify /quote.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If this passes, the quote chains to Intel's root certificate and the measurements are what the quote says they are. That proves the hardware is real. It does not tell you which application is inside.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check 2: match the measurement to a public build
&lt;/h2&gt;

&lt;p&gt;This is three smaller checks. The hash of the application's compose file has to match what the attestation reports. Every image in that compose file has to be pinned by digest, not by a tag. And every image has to carry a signature from our CI on the public GitHub repository.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cosign verify --certificate-identity-regexp &lt;span class="s1"&gt;'github.com/LIT-Protocol/'&lt;/span&gt; \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com \
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;registry&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;image&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;@sha256:&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;digest&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If this passes, the code in the enclave is what CI built from a specific public commit. It does not prove the code is correct. Attestation tells you what is running, not whether it has bugs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check 3: confirm your connection ends in the enclave
&lt;/h2&gt;

&lt;p&gt;An enclave sitting behind a normal load balancer is still exposed, because whoever runs the load balancer can see your traffic. Lit generates the TLS certificate inside the enclave and includes its fingerprint in the attestation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;openssl s_client -connect api.chipotle.litprotocol.com:443 &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;/dev/null 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null \
  &lt;span class="o"&gt;|&lt;/span&gt; openssl x509 -fingerprint -sha256 -noout
dig +short CAA litprotocol.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the live fingerprint matches the attested one, and the CAA record limits who can issue certificates for the domain, then your encrypted connection is going straight into the attested software.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check 4: see who approved the code
&lt;/h2&gt;

&lt;p&gt;An enclave only gets keys if the key management service gives them to it. The service only does that for measurements on an approved list. On Lit, that list is a contract on Base.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cast call &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;DstackApp contract&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"allowedComposeHashes(bytes32)(bool)"&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;compose &lt;span class="nb"&gt;hash&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; \
  --rpc-url https://mainnet.base.org
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adding a hash to the list takes a transaction from a Safe multisig, and those transactions are public. Nobody can add a hash alone, including us. If we deployed a different image tomorrow, it would not get keys until the multisig approved it.&lt;/p&gt;

&lt;p&gt;Most providers keep this step internal. Their enclave software is approved by a group of their own operators or by a release process, and the record lives in their own system. I am not saying their approval is weaker. I am saying you cannot check it without asking them.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you know after the four checks
&lt;/h2&gt;

&lt;p&gt;The hardware is real. The code is a specific public commit. Your connection goes into that code. Someone with recorded authority approved that code to hold keys. What you still do not know is whether the code has bugs, whether the service will stay up, and whether the approvers will make a good decision next time. For those, read the code, plan for downtime, and look at who the signers are.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get started
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://developer.litprotocol.com/architecture/verification/full-verification" rel="noopener noreferrer"&gt;verification guide&lt;/a&gt; has the current endpoints and contract addresses. The &lt;a href="https://developer.litprotocol.com/architecture/verification/onchain-kms" rel="noopener noreferrer"&gt;On-Chain KMS&lt;/a&gt; page explains the four checks the key management service runs before it releases keys.&lt;/p&gt;

&lt;p&gt;This is part 5 of a five-part series on building with Lit. Part 1 covers &lt;a href="https://spark.litprotocol.com/signing-policies-as-code/" rel="noopener noreferrer"&gt;writing signing policies as code&lt;/a&gt;. Part 2 covers &lt;a href="https://spark.litprotocol.com/secrets-for-mcp-servers-and-agents/" rel="noopener noreferrer"&gt;giving Claude Code and MCP servers secrets safely&lt;/a&gt;. Part 3 covers &lt;a href="https://spark.litprotocol.com/backend-signing-without-exposing-keys/" rel="noopener noreferrer"&gt;signing from your backend without exposing the private key&lt;/a&gt;. Part 4 covers &lt;a href="https://spark.litprotocol.com/wallet-api-for-developers/" rel="noopener noreferrer"&gt;adding wallets to your app with an API&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>web3</category>
      <category>blockchain</category>
      <category>javascript</category>
      <category>security</category>
    </item>
    <item>
      <title>How to add wallets to your app with an API</title>
      <dc:creator>Lit Protocol</dc:creator>
      <pubDate>Mon, 16 Nov 2026 21:06:39 +0000</pubDate>
      <link>https://dev.to/litprotocol/how-to-add-wallets-to-your-app-with-an-api-7af</link>
      <guid>https://dev.to/litprotocol/how-to-add-wallets-to-your-app-with-an-api-7af</guid>
      <description>&lt;p&gt;On Lit Protocol you can add a wallet to your app with six REST calls and no SDK. You create a wallet, create a group, write a signing rule, connect them, make an API key for your server, and sign. The key is created and stored inside a secure enclave. The rule that decides when it signs is a JavaScript function that runs in the same enclave. The record of which rules can use which wallets is stored on Base.&lt;/p&gt;

&lt;p&gt;I will walk through the six calls, and then say a little about when Lit is the right choice and when it is not.&lt;/p&gt;

&lt;h2&gt;
  
  
  The six calls
&lt;/h2&gt;

&lt;p&gt;Go to the &lt;a href="https://dashboard.chipotle.litprotocol.com/dapps/dashboard/" rel="noopener noreferrer"&gt;Lit dashboard&lt;/a&gt; and click &lt;strong&gt;Create an account&lt;/strong&gt;. Choose &lt;strong&gt;API key&lt;/strong&gt;, fill in your email and an account name, and copy the account API key it gives you. The base URL for everything below is &lt;code&gt;https://api.chipotle.litprotocol.com/core/v1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;First, create a wallet. You get back an address.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;LIT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https://api.chipotle.litprotocol.com/core/v1
curl -s -X POST &lt;span class="s2"&gt;"$LIT/create_wallet"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt;
&lt;span class="c"&gt;# {"wallet_address":"0x..."}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Second, create a group. A group is how Lit connects wallets, rules, and API keys.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s -X POST &lt;span class="s2"&gt;"$LIT/add_group"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"group_name":"payouts","group_description":"","pkp_ids_permitted":[],"cid_hashes_permitted":[]}'&lt;/span&gt;
&lt;span class="c"&gt;# {"success":true,"group_id":"1"}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Third, write the signing rule. This is a Lit Action. This one checks an allowlist service before it signs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// rule.js&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;pkpId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;valueWei&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;allow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`https://policy.example.com/allow?to=${to}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;allow&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;signed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;allow&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reason&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;provider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;StaticJsonRpcProvider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://mainnet.base.org"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Wallet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;Lit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Actions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getPrivateKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;pkpId&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;populateTransaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;valueWei&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// fills in nonce, gas, fees, and chain ID&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;signed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;signTransaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lit identifies the rule by the IPFS hash of its code. You do not have to upload it anywhere. You can compute the hash yourself, or send the code to the &lt;code&gt;get_lit_action_ipfs_id&lt;/code&gt; endpoint and it will return the hash.&lt;/p&gt;

&lt;p&gt;Fourth, add the rule and the wallet to the group.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s -X POST &lt;span class="s2"&gt;"$LIT/add_action_to_group"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"group_id":1,"action_ipfs_cid":"Qm..."}'&lt;/span&gt;
curl -s -X POST &lt;span class="s2"&gt;"$LIT/add_pkp_to_group"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"group_id":1,"pkp_id":"&amp;lt;pkp id&amp;gt;"}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fifth, make an API key for your server. This key can only execute rules in group 1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s -X POST &lt;span class="s2"&gt;"$LIT/add_usage_api_key"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"name":"payout-service","description":"","can_create_groups":false,"can_delete_groups":false,"can_create_pkps":false,
       "manage_ipfs_ids_in_groups":[],"add_pkp_to_groups":[],"remove_pkp_from_groups":[],"execute_in_groups":[1]}'&lt;/span&gt;
&lt;span class="c"&gt;# {"success":true,"usage_api_key":"..."}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sixth, sign.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jq -n --rawfile code rule.js &lt;span class="s1"&gt;'{code: $code, js_params: {pkpId: "&amp;lt;pkp id&amp;gt;", to: "0xabc...", valueWei: "1000000000000000"}}'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; curl -s -X POST &lt;span class="s2"&gt;"$LIT/lit_action"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $USAGE_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; -d @-
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The enclave hashes the code, checks that your key is allowed to run it against that wallet, runs it, and returns the signed transaction. If you would rather not write curl, there is a JavaScript client that wraps these same calls, and we publish an OpenAPI spec if you want to generate your own.&lt;/p&gt;

&lt;h2&gt;
  
  
  Owning the permissions yourself
&lt;/h2&gt;

&lt;p&gt;By default, Lit holds the account credential and relays your changes. If you switch to ChainSecured mode, a wallet you control owns the account on Base. It can be a regular wallet or a Safe. After that, every change to a group is a transaction you sign, and anyone can read the current permissions from the contract. Your server's key can still run rules. It cannot change them.&lt;/p&gt;

&lt;h2&gt;
  
  
  When Lit is not the right tool
&lt;/h2&gt;

&lt;p&gt;If you need a login flow and a fiat onramp in one SDK, you want an embedded wallet product. If you have a custody obligation and a treasury team, you want a custody platform. Lit is for wallets that your application controls, like hot wallets, vaults, payout services, solvers, and agents. It fits when the signing rule needs real data and when someone outside your company should be able to read what the rule is.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get started
&lt;/h2&gt;

&lt;p&gt;To create an account, go to the &lt;a href="https://dashboard.chipotle.litprotocol.com/dapps/dashboard/" rel="noopener noreferrer"&gt;Lit dashboard&lt;/a&gt; and click &lt;strong&gt;Create an account&lt;/strong&gt;. The quickstart is at &lt;a href="https://developer.litprotocol.com/quickstart" rel="noopener noreferrer"&gt;developer.litprotocol.com/quickstart&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is part 4 of a five-part series on building with Lit. Part 5 is about &lt;a href="https://spark.litprotocol.com/verify-your-hosted-signer/" rel="noopener noreferrer"&gt;verifying the code that signs your transactions&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>web3</category>
      <category>blockchain</category>
      <category>javascript</category>
      <category>security</category>
    </item>
    <item>
      <title>How to sign transactions from your backend without exposing the private key</title>
      <dc:creator>Lit Protocol</dc:creator>
      <pubDate>Mon, 16 Nov 2026 21:01:38 +0000</pubDate>
      <link>https://dev.to/litprotocol/how-to-sign-transactions-from-your-backend-without-exposing-the-private-key-5eal</link>
      <guid>https://dev.to/litprotocol/how-to-sign-transactions-from-your-backend-without-exposing-the-private-key-5eal</guid>
      <description>&lt;p&gt;Keep the private key out of your backend entirely. Put it in a signer your backend calls, and put the rule that decides each signature next to the key instead of in your server. On Lit Protocol the key lives inside a secure enclave, and the rule is a Lit Action, a JavaScript function that runs in that enclave before every signature. Your backend gets an API key that can only request signatures. If someone breaks into your backend, they can ask for signatures that pass your rule, and that is all they can do.&lt;/p&gt;

&lt;p&gt;The way most people start is with a private key in an environment variable and a script that signs locally. I understand why. It works and it is fast to set up. The problem is that anything with access to that process can read the key. And there is nothing between the script's logic and the signature, so a bug in the strategy becomes a signed transaction.&lt;/p&gt;

&lt;h2&gt;
  
  
  The four places a key can live
&lt;/h2&gt;

&lt;p&gt;There are four common designs. They differ in what stands between a compromised backend and a signature.&lt;/p&gt;

&lt;p&gt;The first is a cloud KMS like AWS KMS. The key stays in the HSM and your backend asks it to sign a hash. Nothing stands between your backend and a signature except IAM permissions. The KMS does not know what a blockchain transaction is.&lt;/p&gt;

&lt;p&gt;The second is a hosted signer with a policy engine. The provider holds the key and checks your allowlists and caps before signing. The rule can see the transaction fields. It cannot see your ledger, a price, or whether a deposit landed on another chain.&lt;/p&gt;

&lt;p&gt;The third is a rule written as code that runs inside the enclave with the key. The rule can fetch whatever it needs. This is how Lit works.&lt;/p&gt;

&lt;p&gt;The fourth is a smart account with modules. A Safe or an ERC-4337 account enforces the rule on-chain. This is fully public, but it costs gas per operation, it only works on EVM chains, and the rule can only use data that is already on-chain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Writing the rule on Lit
&lt;/h2&gt;

&lt;p&gt;This Lit Action signs a settlement only after it confirms the deposit on the source chain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// settle-v1.js&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;pkpId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;orderId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`https://indexer.example.com/deposits/${orderId}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;confirmed&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;signed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deposit not confirmed"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;provider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;StaticJsonRpcProvider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://mainnet.base.org"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Wallet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;Lit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Actions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getPrivateKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;pkpId&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;populateTransaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// fills in nonce, gas, fees, and chain ID&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;signed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;signTransaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your backend calls it like this, using the execute-only key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jq -n --rawfile code settle-v1.js &lt;span class="s1"&gt;'{code: $code, js_params: {pkpId: "&amp;lt;pkp&amp;gt;", orderId: "o-123", to: "0x...", amount: "5000000"}}'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; curl -s -X POST https://api.chipotle.litprotocol.com/core/v1/lit_action \
      -H &lt;span class="s2"&gt;"X-Api-Key: $USAGE_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; -d @-
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the request comes in, the enclave hashes the code and checks that your API key is allowed to run that hash against that wallet. Then it runs the function and returns the signed transaction. Lit's code never sends the key out of the enclave, and only the actions in the wallet's group can use it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the execute-only key cannot do
&lt;/h2&gt;

&lt;p&gt;It cannot create a wallet, add a rule, or change a group. Those actions need your account key. If you use ChainSecured mode, they need a transaction from the wallet that owns your account on Base. Keep both of those away from your production servers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some advice that applies no matter what you use
&lt;/h2&gt;

&lt;p&gt;Give each service its own execute-only key, scoped to one group. Put the amount cap and the destination check in the signer's rule, not just in your own code. Test revoking a key before you launch, and notice that the wallet address does not change when you do. Keep the wallet's balance at a working level. A rule stops signatures that break the rule. It cannot undo a mistake that the rule allowed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get started
&lt;/h2&gt;

&lt;p&gt;To create an account, go to the &lt;a href="https://dashboard.chipotle.litprotocol.com/dapps/dashboard/" rel="noopener noreferrer"&gt;Lit dashboard&lt;/a&gt; and click &lt;strong&gt;Create an account&lt;/strong&gt;. The API reference is at &lt;a href="https://developer.litprotocol.com/management/api_direct" rel="noopener noreferrer"&gt;developer.litprotocol.com/management/api_direct&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is part 3 of a five-part series on building with Lit. Part 4 is about &lt;a href="https://spark.litprotocol.com/wallet-api-for-developers/" rel="noopener noreferrer"&gt;adding wallets to your app with an API&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>web3</category>
      <category>blockchain</category>
      <category>javascript</category>
      <category>security</category>
    </item>
    <item>
      <title>How to give Claude Code and MCP servers secrets without handing them the keys</title>
      <dc:creator>Lit Protocol</dc:creator>
      <pubDate>Mon, 16 Nov 2026 20:56:38 +0000</pubDate>
      <link>https://dev.to/litprotocol/how-to-give-claude-code-and-mcp-servers-secrets-without-handing-them-the-keys-3ebo</link>
      <guid>https://dev.to/litprotocol/how-to-give-claude-code-and-mcp-servers-secrets-without-handing-them-the-keys-3ebo</guid>
      <description>&lt;p&gt;The safest way to give an agent access to a secret is to never give it the secret. Agent Keychain is an open-source app built on Lit Protocol that does this. You store a credential, encrypted in your browser. You approve an agent to use it. When the agent needs it, one of two things happens. Either the credential is decrypted on the agent's machine and handed to a process, or Lit uses the credential inside a secure enclave and hands the agent only the result. In the second case the agent never sees the key at all.&lt;/p&gt;

&lt;p&gt;Here is the problem this solves. Agents log everything. Their transcripts get saved, summarized, and sometimes shared. If a Stripe key or a database password ends up in the agent's context, it can end up in all of those places too. A normal secrets manager keeps the key out of your repo, which is good, but when the agent runs a command that needs the key, the key is still in that process. For a live payment key, you want the agent to be able to check a balance without ever holding the key.&lt;/p&gt;

&lt;h2&gt;
  
  
  The two modes
&lt;/h2&gt;

&lt;p&gt;The first mode is called stored secrets. The credential is encrypted in your browser before Keychain stores it. An approved agent fetches the encrypted value, decrypts it on its own machine, and passes it to a child process as an environment variable or a temporary file. Use this when a tool truly needs the raw value.&lt;/p&gt;

&lt;p&gt;The second mode is called connected services. The agent calls an action, such as &lt;code&gt;stripe_balance&lt;/code&gt; or &lt;code&gt;github_read_file&lt;/code&gt;. Each action comes from a public catalog and is pinned to an exact version. Its manifest says which hosts it may contact and what shape of result it may return. Lit runs the action inside the enclave with your credential and returns the result. The agent gets the balance. It does not get the key. There is no way for the agent to export the credential or make the action do something else.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting it up in Claude Code
&lt;/h2&gt;

&lt;p&gt;First, the agent creates its own identity on its machine. Only the public key ever leaves that machine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx @lit-protocol/keychain@2.2.0 init agent-identity.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, sign in at &lt;a href="https://keychain.litprotocol.com" rel="noopener noreferrer"&gt;keychain.litprotocol.com&lt;/a&gt;. You can use Google, a passkey, or a wallet. Add your secrets. Then approve the agent's public key for the secrets and actions you want it to use, and set an expiry. Thirty days is the default.&lt;/p&gt;

&lt;p&gt;Then add Keychain to Claude Code as an MCP server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude mcp add lit-keychain -- npx -y @lit-protocol/keychain@2.2.0 mcp /absolute/path/agent-identity.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is the whole setup. The agent now has tools called &lt;code&gt;list_secrets&lt;/code&gt;, &lt;code&gt;get_secret&lt;/code&gt;, and &lt;code&gt;list_actions&lt;/code&gt;, plus one tool for each connected service you approved. The same identity file works in Cursor or any other MCP client. It works across sessions and across your devices, and you do not have to host anything. If you change an approval, it takes effect on the agent's next request.&lt;/p&gt;

&lt;p&gt;If you want to use a secret in a script instead of an agent, the CLI can pass it to a command without printing it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx @lit-protocol/keychain@2.2.0 run agent-identity.json --only STRIPE_KEY -- ./deploy.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What Keychain's operator can and cannot do
&lt;/h2&gt;

&lt;p&gt;Keychain's storage service holds encrypted values and permission records that you signed. It cannot decrypt a secret, because it does not have your key. It cannot approve an agent or extend an approval, because you sign those. It cannot change what a connected-service action returns, because the enclave signs the response. Before every request, the client checks the hardware attestation and the on-chain list of approved runtime versions.&lt;/p&gt;

&lt;p&gt;There are things the operator can do. It can refuse service. It can keep serving an older approval until that approval expires. And when you revoke an agent, that takes effect on the next request. Anything the agent already received stays with the agent.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does not protect against
&lt;/h2&gt;

&lt;p&gt;If a stored secret is delivered to a child process, it is plaintext on that machine, and the child process can log it. Connected services send your credential to the upstream provider over TLS, so you are trusting the provider with it, same as always. Contract wallets cannot be owner credentials yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get started
&lt;/h2&gt;

&lt;p&gt;Keychain is free for five secrets and $10 a month for up to a thousand. The &lt;a href="https://keychain.litprotocol.com/SKILL.md" rel="noopener noreferrer"&gt;setup guide&lt;/a&gt; is written so you can paste it to your agent. The &lt;a href="https://keychain.litprotocol.com/SECURITY.md" rel="noopener noreferrer"&gt;security model&lt;/a&gt; has the full details.&lt;/p&gt;

&lt;p&gt;This is part 2 of a five-part series on building with Lit. Part 3 is about &lt;a href="https://spark.litprotocol.com/backend-signing-without-exposing-keys/" rel="noopener noreferrer"&gt;signing from your backend without exposing the private key&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>security</category>
      <category>web3</category>
    </item>
    <item>
      <title>How to write wallet signing policies as code</title>
      <dc:creator>Lit Protocol</dc:creator>
      <pubDate>Mon, 16 Nov 2026 20:51:37 +0000</pubDate>
      <link>https://dev.to/litprotocol/how-to-write-wallet-signing-policies-as-code-4g5m</link>
      <guid>https://dev.to/litprotocol/how-to-write-wallet-signing-policies-as-code-4g5m</guid>
      <description>&lt;p&gt;On Lit Protocol, a signing policy is a JavaScript function called a Lit Action. It runs inside the same secure enclave that holds the key. Before it signs, it can call any API, read any chain, and check any condition you want. If the check fails, it does not sign. You attach the function to a wallet by its content hash, and that permission is recorded on Base.&lt;/p&gt;

&lt;p&gt;I want to explain why we built it this way, and then show you the code.&lt;/p&gt;

&lt;p&gt;Most wallet providers let you set rules in a dashboard. You can allow certain addresses and cap the amount. Those rules can only look at the transaction itself. They cannot look at your ledger, a price feed, or a deposit on another chain. So if your rule is "only sign this settlement after the deposit has confirmed," you have to check that in your own server before you ask for the signature. That puts the check back in the place you were trying not to trust.&lt;/p&gt;

&lt;p&gt;With a Lit Action, the check and the signature happen in the same place. Your server cannot skip the check because your server never touches the key.&lt;/p&gt;

&lt;h2&gt;
  
  
  Write the policy
&lt;/h2&gt;

&lt;p&gt;Here is a policy that signs a transfer only if the recipient passes a screening check and the day's spending stays under a cap.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// policy-transfer-v1.js&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;pkpId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;recipient&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amountUsd&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`https://screening.example.com/check/${recipient}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;screen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clear&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;signed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"recipient flagged"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ledger&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`https://ledger.example.com/spend/today?wallet=${tx.from}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;spentUsd&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;amountUsd&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;25000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;signed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"daily cap"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Wallet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;Lit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Actions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getPrivateKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;pkpId&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;signed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;signedTx&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;signTransaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both of those fetch calls run inside the enclave. The cap and the screening URL are part of the code. Lit identifies the policy by the IPFS hash of its code, and that hash is the policy's identity. You do not have to upload the file anywhere. The &lt;code&gt;get_lit_action_ipfs_id&lt;/code&gt; endpoint returns the hash for any code you send it. If you change anything in the file, you get a different hash, and the wallet will not run it until you approve it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Attach it to a wallet
&lt;/h2&gt;

&lt;p&gt;Lit uses groups to connect wallets, policies, and API keys. You add the policy and the wallet to the same group.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s -X POST https://api.chipotle.litprotocol.com/core/v1/add_action_to_group \
  -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"group_id":1,"action_ipfs_cid":"&amp;lt;policy-transfer-v1 CID&amp;gt;"}'&lt;/span&gt;

curl -s -X POST https://api.chipotle.litprotocol.com/core/v1/add_pkp_to_group \
  -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"group_id":1,"pkp_id":"&amp;lt;pkp id&amp;gt;"}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Groups live in smart contracts on Base. If you switch your account to ChainSecured mode, a wallet you control owns the account, and every change to a group is a transaction you sign. Anyone can look at the contract and see which policies a wallet trusts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give your server a key that can only execute
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s -X POST https://api.chipotle.litprotocol.com/core/v1/add_usage_api_key \
  -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"name":"payouts","description":"","can_create_groups":false,"can_delete_groups":false,"can_create_pkps":false,
       "manage_ipfs_ids_in_groups":[],"add_pkp_to_groups":[],"remove_pkp_from_groups":[],"execute_in_groups":[1]}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This key can run the policies in group 1 against the wallets in group 1. It cannot add a policy, add a wallet, or change the group. If someone steals it, the most they can do is request signatures that already pass your policy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Change the policy later
&lt;/h2&gt;

&lt;p&gt;Write a new version of the file and get its hash. Add the new hash to the group and remove the old one. The wallet address stays the same. The record of which policies were allowed, and when, stays on Base.&lt;/p&gt;

&lt;h2&gt;
  
  
  A few things to keep in mind
&lt;/h2&gt;

&lt;p&gt;Treat the policy like production code, because that is what it is. A bug in the cap check is a signed transaction. The services your policy calls are part of your trust model, so pin the hostnames and validate what comes back. And keep the wallet's balance at a working level, since a policy stops out-of-policy signatures but cannot undo a mistake that passed the policy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get started
&lt;/h2&gt;

&lt;p&gt;To create an account, go to the &lt;a href="https://dashboard.chipotle.litprotocol.com/dapps/dashboard/" rel="noopener noreferrer"&gt;Lit dashboard&lt;/a&gt; and click &lt;strong&gt;Create an account&lt;/strong&gt;. The Lit Actions docs are at &lt;a href="https://developer.litprotocol.com/lit-actions" rel="noopener noreferrer"&gt;developer.litprotocol.com/lit-actions&lt;/a&gt;, and groups are covered at &lt;a href="https://developer.litprotocol.com/architecture/groups" rel="noopener noreferrer"&gt;developer.litprotocol.com/architecture/groups&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is part 1 of a five-part series on building with Lit. Part 2 is about &lt;a href="https://spark.litprotocol.com/secrets-for-mcp-servers-and-agents/" rel="noopener noreferrer"&gt;giving Claude Code and MCP servers secrets safely&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>web3</category>
      <category>blockchain</category>
      <category>javascript</category>
      <category>security</category>
    </item>
    <item>
      <title>How to give your AI agent a crypto wallet</title>
      <dc:creator>Lit Protocol</dc:creator>
      <pubDate>Mon, 16 Nov 2026 20:51:18 +0000</pubDate>
      <link>https://dev.to/litprotocol/how-to-give-your-ai-agent-a-crypto-wallet-5ghm</link>
      <guid>https://dev.to/litprotocol/how-to-give-your-ai-agent-a-crypto-wallet-5ghm</guid>
      <description>&lt;p&gt;To give an AI agent a crypto wallet, give it a tool that asks for a payment, and keep the private key and the rules somewhere the agent cannot reach. On Lit Protocol the key lives inside a secure enclave. The rules are a JavaScript function, called a Lit Action, that runs in the same enclave before every signature. The agent gets an API key that can run that one function. It can ask for payments that follow your rules, and it cannot read the key or change the rules.&lt;/p&gt;

&lt;p&gt;The reason to set it up this way is that an agent does what its context tells it to. If a web page or an email it reads contains a prompt injection, the agent may try to send money somewhere you did not intend. If the agent holds the private key, nothing stops it. If the rules live next to the key, the worst it can do is make a payment that passes the rules.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rules
&lt;/h2&gt;

&lt;p&gt;This action lets the agent pay vendors in USDC on Base. It only pays addresses on an allowlist, and never more than 20 USDC at a time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// agent-pay.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;USDC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;VENDORS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"0xDataVendor..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"0xComputeVendor..."&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;MAX&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20_000000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// 20 USDC, which has 6 decimals&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;pkpId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="no"&gt;VENDORS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;paid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"not an approved vendor"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="no"&gt;MAX&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;paid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"amount must be between 0 and 20 USDC"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;provider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;StaticJsonRpcProvider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://mainnet.base.org"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Wallet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;Lit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Actions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getPrivateKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;pkpId&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;usdc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Contract&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;USDC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"function transfer(address,uint256) returns (bool)"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wallet&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;usdc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;paid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hash&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The reasons it returns go back to the agent, so it can tell the user why a payment did not happen.&lt;/p&gt;

&lt;p&gt;The simplest total limit is the wallet's balance. Put in what the agent is allowed to spend this week and nothing more. If you want a daily cap that holds no matter how much is in the wallet, the action can read your own spending record before it signs. The post on &lt;a href="https://spark.litprotocol.com/signing-policies-as-code/" rel="noopener noreferrer"&gt;writing signing policies as code&lt;/a&gt; shows that pattern.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting it up
&lt;/h2&gt;

&lt;p&gt;Go to the &lt;a href="https://dashboard.chipotle.litprotocol.com/dapps/dashboard/" rel="noopener noreferrer"&gt;Lit dashboard&lt;/a&gt; and click &lt;strong&gt;Create an account&lt;/strong&gt;. Choose &lt;strong&gt;API key&lt;/strong&gt;, fill in your email and an account name, and copy the account API key it gives you. Add some credit with &lt;strong&gt;Add Funds&lt;/strong&gt;. Then create a wallet, put it and the action in a group, and make an API key for the agent that can only run that group.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;LIT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https://api.chipotle.litprotocol.com/core/v1
&lt;span class="nv"&gt;WALLET&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;curl -s -X POST &lt;span class="s2"&gt;"$LIT/create_wallet"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; jq -r .wallet_address&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$WALLET&lt;/span&gt;   &lt;span class="c"&gt;# the agent's wallet address&lt;/span&gt;
&lt;span class="nv"&gt;CID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;jq -Rs . agent-pay.js &lt;span class="o"&gt;|&lt;/span&gt; curl -s -X POST &lt;span class="s2"&gt;"$LIT/get_lit_action_ipfs_id"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; -d @- &lt;span class="o"&gt;|&lt;/span&gt; jq -r .&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="nv"&gt;GROUP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;curl -s -X POST &lt;span class="s2"&gt;"$LIT/add_group"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"group_name":"agent","group_description":"","pkp_ids_permitted":[],"cid_hashes_permitted":[]}'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; jq -r .group_id&lt;span class="o"&gt;)&lt;/span&gt;
curl -s -X POST &lt;span class="s2"&gt;"$LIT/add_action_to_group"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s2"&gt;"{\"group_id\":$GROUP,\"action_ipfs_cid\":\"$CID\"}"&lt;/span&gt;
curl -s -X POST &lt;span class="s2"&gt;"$LIT/add_pkp_to_group"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s2"&gt;"{\"group_id\":$GROUP,\"pkp_id\":\"$WALLET\"}"&lt;/span&gt;
&lt;span class="nv"&gt;USAGE_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;curl -s -X POST &lt;span class="s2"&gt;"$LIT/add_usage_api_key"&lt;/span&gt; -H &lt;span class="s2"&gt;"X-Api-Key: $ACCOUNT_KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"name":"agent","description":"","can_create_groups":false,"can_delete_groups":false,"can_create_pkps":false,
       "manage_ipfs_ids_in_groups":[],"add_pkp_to_groups":[],"remove_pkp_from_groups":[],"execute_in_groups":['&lt;/span&gt;&lt;span class="s2"&gt;"$GROUP"&lt;/span&gt;&lt;span class="s1"&gt;']}'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; jq -r .usage_api_key&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Send USDC to the wallet address, plus a little ETH on Base for gas. New permissions can take up to 30 seconds to start working, so wait a minute before the agent's first payment, or retry it if it is refused.&lt;/p&gt;

&lt;h2&gt;
  
  
  The agent's tool
&lt;/h2&gt;

&lt;p&gt;The agent sees a tool with a name, a description, and two inputs. When it calls the tool, your code sends the action and the inputs to Lit. The definition uses the tool format from the Anthropic API, with a &lt;code&gt;run&lt;/code&gt; function that your code calls when the agent uses the tool. Other agent frameworks use almost the same shape.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;readFileSync&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"node:fs"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;CODE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;readFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"agent-pay.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"utf8"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;payVendor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"pay_vendor"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Pay an approved vendor in USDC on Base. At most 20 USDC per payment."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;input_schema&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"object"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"string"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount_usdc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"number"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"to"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"amount_usdc"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount_usdc&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://api.chipotle.litprotocol.com/core/v1/lit_action"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"POST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;"X-Api-Key"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;LIT_USAGE_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"application/json"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;CODE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;js_params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;pkpId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;AGENT_WALLET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amount_usdc&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;1e6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;paid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;"string"&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="sb"&gt;`Lit returned ${res.status}`&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set &lt;code&gt;LIT_USAGE_KEY&lt;/code&gt; to the usage key and &lt;code&gt;AGENT_WALLET&lt;/code&gt; to the wallet address from the setup step. The limit in the description is only there to help the agent choose well. The limit that counts is the one in the action.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the agent can and cannot do
&lt;/h2&gt;

&lt;p&gt;With the usage key, the agent can run agent-pay.js against that one wallet. It cannot read the private key. It cannot add a new action, change the allowlist, or raise the limit, because those need your account key, and changing the code gives it a new hash that the agent's key is not allowed to run. To stop the agent, delete its usage key. It can take up to five minutes to stop working everywhere. The wallet and its money stay where they are.&lt;/p&gt;

&lt;p&gt;The usage key is still a credential, so keep it out of the agent's transcript. &lt;a href="https://keychain.litprotocol.com" rel="noopener noreferrer"&gt;Agent Keychain&lt;/a&gt; can store it and pass it to the tool's process without the agent seeing it. The same goes for any other API keys the agent needs. The post on &lt;a href="https://spark.litprotocol.com/secrets-for-mcp-servers-and-agents/" rel="noopener noreferrer"&gt;giving Claude Code and MCP servers secrets&lt;/a&gt; walks through the setup.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get started
&lt;/h2&gt;

&lt;p&gt;To create an account, go to the &lt;a href="https://dashboard.chipotle.litprotocol.com/dapps/dashboard/" rel="noopener noreferrer"&gt;Lit dashboard&lt;/a&gt; and click &lt;strong&gt;Create an account&lt;/strong&gt;. The quickstart is at &lt;a href="https://developer.litprotocol.com/quickstart" rel="noopener noreferrer"&gt;developer.litprotocol.com/quickstart&lt;/a&gt;, and Agent Keychain is documented at &lt;a href="https://developer.litprotocol.com/keychain/index" rel="noopener noreferrer"&gt;developer.litprotocol.com/keychain&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>security</category>
      <category>web3</category>
    </item>
  </channel>
</rss>
