@avalanche-sdk/client
Version:
A TypeScript SDK for interacting with the Avalanche network through JSON-RPC APIs. This SDK provides a comprehensive set of tools to interact with all Avalanche chains (P-Chain, X-Chain, C-Chain) and various APIs, including wallet functionality for transa
2 lines • 278 kB
JavaScript
import{defineChain as e}from"viem";function t(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}const a=t({id:16600,name:"0G Newton Testnet",nativeCurrency:{name:"A0GI",symbol:"A0GI",decimals:18},rpcUrls:{default:{http:["https://evmrpc-testnet.0g.ai"]}},blockExplorers:{default:{name:"0G BlockChain Explorer",url:"https://chainscan-newton.0g.ai"}},testnet:!0}),r=t({id:995,name:"5ireChain",nativeCurrency:{name:"5ire Token",symbol:"5IRE",decimals:18},rpcUrls:{default:{http:["https://rpc.5ire.network"]}},blockExplorers:{default:{name:"5ireChain Mainnet Explorer",url:"https://5irescan.io/"}},testnet:!1}),s=t({id:179,name:"ABEY Mainnet",nativeCurrency:{name:"ABEY",symbol:"ABEY",decimals:18},rpcUrls:{default:{http:["https://rpc.abeychain.com"]}},blockExplorers:{default:{name:"Abey Scan",url:"https://abeyscan.com"}},testnet:!1}),n="2.38.2";let l=({docsBaseUrl:e,docsPath:t="",docsSlug:a})=>t?`${e??"https://viem.sh"}${t}${a?`#${a}`:""}`:void 0,o=`viem@${n}`;class c extends Error{constructor(e,t={}){const a=t.cause instanceof c?t.cause.details:t.cause?.message?t.cause.message:t.details,r=t.cause instanceof c&&t.cause.docsPath||t.docsPath,s=l?.({...t,docsPath:r});super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...a?[`Details: ${a}`]:[],...o?[`Version: ${o}`]:[]].join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=a,this.docsPath=r,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=n}walk(e){return i(this,e)}}function i(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&void 0!==e.cause?i(e.cause,t):t?null:e}class p extends c{constructor({max:e,min:t,signed:a,size:r,value:s}){super(`Number "${s}" is not in safe ${r?`${8*r}-bit ${a?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class d extends c{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function m(e,{strict:t=!0}={}){return!!e&&("string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")))}function u(e){return m(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}function h(e,{dir:t="left"}={}){let a="string"==typeof e?e.replace("0x",""):e,r=0;for(let e=0;e<a.length-1&&"0"===a["left"===t?e:a.length-e-1].toString();e++)r++;return a="left"===t?a.slice(r):a.slice(0,a.length-r),"string"==typeof e?(1===a.length&&"right"===t&&(a=`${a}0`),`0x${a.length%2==1?`0${a}`:a}`):a}class b extends c{constructor({offset:e,position:t,size:a}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${a}).`,{name:"SliceOffsetOutOfBoundsError"})}}class x extends c{constructor({size:e,targetSize:t,type:a}){super(`${a.charAt(0).toUpperCase()}${a.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}function f(e,{dir:t,size:a=32}={}){return"string"==typeof e?function(e,{dir:t,size:a=32}={}){if(null===a)return e;const r=e.replace("0x","");if(r.length>2*a)throw new x({size:Math.ceil(r.length/2),targetSize:a,type:"hex"});return`0x${r["right"===t?"padEnd":"padStart"](2*a,"0")}`}(e,{dir:t,size:a}):function(e,{dir:t,size:a=32}={}){if(null===a)return e;if(e.length>a)throw new x({size:e.length,targetSize:a,type:"bytes"});const r=new Uint8Array(a);for(let s=0;s<a;s++){const n="right"===t;r[n?s:a-s-1]=e[n?s:e.length-s-1]}return r}(e,{dir:t,size:a})}const y=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function k(e,t={}){return"number"==typeof e||"bigint"==typeof e?C(e,t):"string"==typeof e?function(e,t={}){const a=v.encode(e);return E(a,t)}(e,t):"boolean"==typeof e?function(e,t={}){const a=`0x${Number(e)}`;if("number"==typeof t.size)return S(a,{size:t.size}),f(a,{size:t.size});return a}(e,t):E(e,t)}function E(e,t={}){let a="";for(let t=0;t<e.length;t++)a+=y[e[t]];const r=`0x${a}`;return"number"==typeof t.size?(S(r,{size:t.size}),f(r,{dir:"right",size:t.size})):r}function C(e,t={}){const{signed:a,size:r}=t,s=BigInt(e);let n;r?n=a?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(n=BigInt(Number.MAX_SAFE_INTEGER));const l="bigint"==typeof n&&a?-n-1n:0;if(n&&s>n||s<l){const t="bigint"==typeof e?"n":"";throw new p({max:n?`${n}${t}`:void 0,min:`${l}${t}`,signed:a,size:r,value:`${e}${t}`})}const o=`0x${(a&&s<0?(1n<<BigInt(8*r))+BigInt(s):s).toString(16)}`;return r?f(o,{size:r}):o}const v=new TextEncoder;const w=new TextEncoder;function g(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){const a=C(e,t);return T(a)}(e,t):"boolean"==typeof e?function(e,t={}){const a=new Uint8Array(1);if(a[0]=Number(e),"number"==typeof t.size)return S(a,{size:t.size}),f(a,{size:t.size});return a}(e,t):m(e)?T(e,t):B(e,t)}const U={zero:48,nine:57,A:65,F:70,a:97,f:102};function A(e){return e>=U.zero&&e<=U.nine?e-U.zero:e>=U.A&&e<=U.F?e-(U.A-10):e>=U.a&&e<=U.f?e-(U.a-10):void 0}function T(e,t={}){let a=e;t.size&&(S(a,{size:t.size}),a=f(a,{dir:"right",size:t.size}));let r=a.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,n=new Uint8Array(s);for(let e=0,t=0;e<s;e++){const a=A(r.charCodeAt(t++)),s=A(r.charCodeAt(t++));if(void 0===a||void 0===s)throw new c(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);n[e]=16*a+s}return n}function B(e,t={}){const a=w.encode(e);return"number"==typeof t.size?(S(a,{size:t.size}),f(a,{dir:"right",size:t.size})):a}function S(e,{size:t}){if(u(e)>t)throw new d({givenSize:u(e),maxSize:t})}function F(e,t={}){const{signed:a}=t;t.size&&S(e,{size:t.size});const r=BigInt(e);if(!a)return r;const s=(e.length-2)/2;return r<=(1n<<8n*BigInt(s)-1n)-1n?r:r-BigInt(`0x${"f".padStart(2*s,"f")}`)-1n}function D(e,t={}){return Number(F(e,t))}function P(e,t){return({exclude:a,format:r})=>({exclude:a,format:(e,s)=>{const n=t(e,s);if(a)for(const e of a)delete n[e];return{...n,...r(e,s)}},type:e})}const z={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function I(e,t){const a={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?D(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?D(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?z[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(a.authorizationList=e.authorizationList.map(e=>({address:e.address,chainId:Number(e.chainId),nonce:Number(e.nonce),r:e.r,s:e.s,yParity:Number(e.yParity)}))),a.yParity=(()=>{if(e.yParity)return Number(e.yParity);if("bigint"==typeof a.v){if(0n===a.v||27n===a.v)return 0;if(1n===a.v||28n===a.v)return 1;if(a.v>=35n)return a.v%2n==0n?1:0}})(),"legacy"===a.type&&(delete a.accessList,delete a.maxFeePerBlobGas,delete a.maxFeePerGas,delete a.maxPriorityFeePerGas,delete a.yParity),"eip2930"===a.type&&(delete a.maxFeePerBlobGas,delete a.maxFeePerGas,delete a.maxPriorityFeePerGas),"eip1559"===a.type&&delete a.maxFeePerBlobGas,a}const M=P("transaction",I);function L(e,t){const a=(e.transactions??[]).map(e=>"string"==typeof e?e:I(e));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:a,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}const O=P("block",L);function H(e,{args:t,eventName:a}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...a?{args:t,eventName:a}:{}}}const N={"0x0":"reverted","0x1":"success"};function G(e,t){const a={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map(e=>H(e)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?D(e.transactionIndex):null,status:e.status?N[e.status]:null,type:e.type?z[e.type]||e.type:null};return e.blobGasPrice&&(a.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(a.blobGasUsed=BigInt(e.blobGasUsed)),a}const R=P("transactionReceipt",G),V={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function K(e,t){const a={};return void 0!==e.authorizationList&&(a.authorizationList=e.authorizationList.map(e=>({address:e.address,r:e.r?C(BigInt(e.r)):e.r,s:e.s?C(BigInt(e.s)):e.s,chainId:C(e.chainId),nonce:C(e.nonce),...void 0!==e.yParity?{yParity:C(e.yParity)}:{},...void 0!==e.v&&void 0===e.yParity?{v:C(e.v)}:{}}))),void 0!==e.accessList&&(a.accessList=e.accessList),void 0!==e.blobVersionedHashes&&(a.blobVersionedHashes=e.blobVersionedHashes),void 0!==e.blobs&&("string"!=typeof e.blobs[0]?a.blobs=e.blobs.map(e=>E(e)):a.blobs=e.blobs),void 0!==e.data&&(a.data=e.data),void 0!==e.from&&(a.from=e.from),void 0!==e.gas&&(a.gas=C(e.gas)),void 0!==e.gasPrice&&(a.gasPrice=C(e.gasPrice)),void 0!==e.maxFeePerBlobGas&&(a.maxFeePerBlobGas=C(e.maxFeePerBlobGas)),void 0!==e.maxFeePerGas&&(a.maxFeePerGas=C(e.maxFeePerGas)),void 0!==e.maxPriorityFeePerGas&&(a.maxPriorityFeePerGas=C(e.maxPriorityFeePerGas)),void 0!==e.nonce&&(a.nonce=C(e.nonce)),void 0!==e.to&&(a.to=e.to),void 0!==e.type&&(a.type=V[e.type]),void 0!==e.value&&(a.value=C(e.value)),a}const X=P("transactionRequest",K);const j=2n**256n-1n,$=50000n,q=2097120n,Z={block:O({format(e){const t=e.transactions?.map(e=>{if("string"==typeof e)return e;const t=Z.transaction?.format(e);return"0x71"===t.typeHex?t.type="eip712":"0xff"===t.typeHex&&(t.type="priority"),t});return{l1BatchNumber:e.l1BatchNumber?F(e.l1BatchNumber):null,l1BatchTimestamp:e.l1BatchTimestamp?F(e.l1BatchTimestamp):null,transactions:t}}}),transaction:M({format(e){const t={};return"0x71"===e.type?t.type="eip712":"0xff"===e.type&&(t.type="priority"),{...t,l1BatchNumber:e.l1BatchNumber?F(e.l1BatchNumber):null,l1BatchTxIndex:e.l1BatchTxIndex?F(e.l1BatchTxIndex):null}}}),transactionReceipt:R({format:e=>({l1BatchNumber:e.l1BatchNumber?F(e.l1BatchNumber):null,l1BatchTxIndex:e.l1BatchTxIndex?F(e.l1BatchTxIndex):null,logs:e.logs.map(e=>({...H(e),l1BatchNumber:e.l1BatchNumber?F(e.l1BatchNumber):null,transactionLogIndex:D(e.transactionLogIndex),logType:e.logType})),l2ToL1Logs:e.l2ToL1Logs.map(e=>({blockNumber:F(e.blockHash),blockHash:e.blockHash,l1BatchNumber:e.l1BatchNumber?F(e.l1BatchNumber):null,transactionIndex:F(e.transactionIndex),shardId:F(e.shardId),isService:e.isService,sender:e.sender,key:e.key,value:e.value,transactionHash:e.transactionHash,logIndex:F(e.logIndex)}))})}),transactionRequest:X({exclude:["customSignature","factoryDeps","gasPerPubdata","paymaster","paymasterInput"],format:e=>e.gasPerPubdata||e.paymaster&&e.paymasterInput||e.factoryDeps||e.customSignature?{eip712Meta:{...e.gasPerPubdata?{gasPerPubdata:k(e.gasPerPubdata)}:{gasPerPubdata:k($)},...e.paymaster&&e.paymasterInput?{paymasterParams:{paymaster:e.paymaster,paymasterInput:Array.from(T(e.paymasterInput))}}:{},...e.factoryDeps?{factoryDeps:e.factoryDeps.map(e=>Array.from(T(e)))}:{},...e.customSignature?{customSignature:Array.from(T(e.customSignature))}:{}},type:"0x71"}:{}})};function W(e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}class J extends c{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class Y extends c{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}}class Q extends c{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}}const _={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new Q({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new Y({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new J({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new J({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const a=t??this.position;return this.assertPosition(a+e-1),this.bytes.subarray(a,a+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,255&e),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const a=this.inspectBytes(e);return this.position+=t??e,a},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};function ee(e,{recursiveReadLimit:t=8192}={}){const a=Object.create(_);return a.bytes=e,a.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),a.positionReadCount=new Map,a.recursiveReadLimit=t,a}function te(e,t="hex"){const a=ae(e),r=ee(new Uint8Array(a.length));return a.encode(r),"hex"===t?E(r.bytes):r.bytes}function ae(e){return Array.isArray(e)?function(e){const t=e.reduce((e,t)=>e+t.length,0),a=re(t);return{length:t<=55?1+t:1+a+t,encode(r){t<=55?r.pushByte(192+t):(r.pushByte(247+a),1===a?r.pushUint8(t):2===a?r.pushUint16(t):3===a?r.pushUint24(t):r.pushUint32(t));for(const{encode:t}of e)t(r)}}}(e.map(e=>ae(e))):function(e){const t="string"==typeof e?T(e):e,a=re(t.length),r=1===t.length&&t[0]<128?1:t.length<=55?1+t.length:1+a+t.length;return{length:r,encode(e){1===t.length&&t[0]<128?e.pushBytes(t):t.length<=55?(e.pushByte(128+t.length),e.pushBytes(t)):(e.pushByte(183+a),1===a?e.pushUint8(t.length):2===a?e.pushUint16(t.length):3===a?e.pushUint24(t.length):e.pushUint32(t.length),e.pushBytes(t))}}}(e)}function re(e){if(e<256)return 1;if(e<65536)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new c("Length is too large.")}const se={gwei:9,wei:18},ne={ether:-9,wei:9};function le(e,t){let a=e.toString();const r=a.startsWith("-");r&&(a=a.slice(1)),a=a.padStart(t,"0");let[s,n]=[a.slice(0,a.length-t),a.slice(a.length-t)];return n=n.replace(/(0+)$/,""),`${r?"-":""}${s||"0"}${n?`.${n}`:""}`}function oe(e,t="wei"){return le(e,se[t])}function ce(e,t="wei"){return le(e,ne[t])}function ie(e){const t=Object.entries(e).map(([e,t])=>void 0===t||!1===t?null:[e,t]).filter(Boolean),a=t.reduce((e,[t])=>Math.max(e,t.length),0);return t.map(([e,t])=>` ${`${e}:`.padEnd(a+1)} ${t}`).join("\n")}class pe extends c{constructor(){super(["Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.","Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others."].join("\n"),{name:"FeeConflictError"})}}class de extends c{constructor({v:e}){super(`Invalid \`v\` value "${e}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}}class me extends c{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",ie(e),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class ue extends c{constructor({storageKey:e}){super(`Size for storage key "${e}" is invalid. Expected 32 bytes. Got ${Math.floor((e.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}function he(e){const{kzg:t}=e,a=e.to??("string"==typeof e.blobs[0]?"hex":"bytes"),r="string"==typeof e.blobs[0]?e.blobs.map(e=>T(e)):e.blobs,s=[];for(const e of r)s.push(Uint8Array.from(t.blobToKzgCommitment(e)));return"bytes"===a?s:s.map(e=>E(e))}function be(e){const{kzg:t}=e,a=e.to??("string"==typeof e.blobs[0]?"hex":"bytes"),r="string"==typeof e.blobs[0]?e.blobs.map(e=>T(e)):e.blobs,s="string"==typeof e.commitments[0]?e.commitments.map(e=>T(e)):e.commitments,n=[];for(let e=0;e<r.length;e++){const a=r[e],l=s[e];n.push(Uint8Array.from(t.computeBlobKzgProof(a,l)))}return"bytes"===a?n:n.map(e=>E(e))}
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function xe(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function fe(e,...t){if(!((a=e)instanceof Uint8Array||ArrayBuffer.isView(a)&&"Uint8Array"===a.constructor.name))throw new Error("Uint8Array expected");var a;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function ye(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function ke(e,t){fe(e);const a=t.outputLen;if(e.length<a)throw new Error("digestInto() expects output buffer of length at least "+a)}function Ee(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ce(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ve(e,t){return e<<32-t|e>>>t}function we(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const ge=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=we(e[t]);return e};function Ue(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),fe(e),e}class Ae{}function Te(e){const t=t=>e().update(Ue(t)).digest(),a=e();return t.outputLen=a.outputLen,t.blockLen=a.blockLen,t.create=()=>e(),t}function Be(e,t,a){return e&t^~e&a}function Se(e,t,a){return e&t^e&a^t&a}class Fe extends Ae{constructor(e,t,a,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=a,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Ce(this.buffer)}update(e){ye(this),fe(e=Ue(e));const{view:t,buffer:a,blockLen:r}=this,s=e.length;for(let n=0;n<s;){const l=Math.min(r-this.pos,s-n);if(l===r){const t=Ce(e);for(;r<=s-n;n+=r)this.process(t,n);continue}a.set(e.subarray(n,n+l),this.pos),this.pos+=l,n+=l,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ye(this),ke(e,this),this.finished=!0;const{buffer:t,view:a,blockLen:r,isLE:s}=this;let{pos:n}=this;t[n++]=128,Ee(this.buffer.subarray(n)),this.padOffset>r-n&&(this.process(a,0),n=0);for(let e=n;e<r;e++)t[e]=0;!function(e,t,a,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,a,r);const s=BigInt(32),n=BigInt(4294967295),l=Number(a>>s&n),o=Number(a&n),c=r?4:0,i=r?0:4;e.setUint32(t+c,l,r),e.setUint32(t+i,o,r)}(a,r-8,BigInt(8*this.length),s),this.process(a,0);const l=Ce(e),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=o/4,i=this.get();if(c>i.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)l.setUint32(4*e,i[e],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const a=e.slice(0,t);return this.destroy(),a}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:a,length:r,finished:s,destroyed:n,pos:l}=this;return e.destroyed=n,e.finished=s,e.length=r,e.pos=l,r%t&&e.buffer.set(a),e}clone(){return this._cloneInto()}}const De=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Pe=BigInt(2**32-1),ze=BigInt(32);function Ie(e,t=!1){return t?{h:Number(e&Pe),l:Number(e>>ze&Pe)}:{h:0|Number(e>>ze&Pe),l:0|Number(e&Pe)}}const Me=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Le=new Uint32Array(64);class Oe extends Fe{constructor(e=32){super(64,e,8,!1),this.A=0|De[0],this.B=0|De[1],this.C=0|De[2],this.D=0|De[3],this.E=0|De[4],this.F=0|De[5],this.G=0|De[6],this.H=0|De[7]}get(){const{A:e,B:t,C:a,D:r,E:s,F:n,G:l,H:o}=this;return[e,t,a,r,s,n,l,o]}set(e,t,a,r,s,n,l,o){this.A=0|e,this.B=0|t,this.C=0|a,this.D=0|r,this.E=0|s,this.F=0|n,this.G=0|l,this.H=0|o}process(e,t){for(let a=0;a<16;a++,t+=4)Le[a]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Le[e-15],a=Le[e-2],r=ve(t,7)^ve(t,18)^t>>>3,s=ve(a,17)^ve(a,19)^a>>>10;Le[e]=s+Le[e-7]+r+Le[e-16]|0}let{A:a,B:r,C:s,D:n,E:l,F:o,G:c,H:i}=this;for(let e=0;e<64;e++){const t=i+(ve(l,6)^ve(l,11)^ve(l,25))+Be(l,o,c)+Me[e]+Le[e]|0,p=(ve(a,2)^ve(a,13)^ve(a,22))+Se(a,r,s)|0;i=c,c=o,o=l,l=n+t|0,n=s,s=r,r=a,a=t+p|0}a=a+this.A|0,r=r+this.B|0,s=s+this.C|0,n=n+this.D|0,l=l+this.E|0,o=o+this.F|0,c=c+this.G|0,i=i+this.H|0,this.set(a,r,s,n,l,o,c,i)}roundClean(){Ee(Le)}destroy(){this.set(0,0,0,0,0,0,0,0),Ee(this.buffer)}}const He=Te(()=>new Oe);function Ne(e,t){const a=t||"hex",r=He(m(e,{strict:!1})?g(e):e);return"bytes"===a?r:k(r)}function Ge(e){const{commitment:t,version:a=1}=e,r=e.to??("string"==typeof t?"hex":"bytes"),s=Ne(t,"bytes");return s.set([a],0),"bytes"===r?s:E(s)}const Re=4096,Ve=131072,Ke=761855;class Xe extends c{constructor({maxSize:e,size:t}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${t} bytes`],name:"BlobSizeTooLargeError"})}}class je extends c{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class $e extends c{constructor({hash:e,size:t}){super(`Versioned hash "${e}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${t}`],name:"InvalidVersionedHashSizeError"})}}class qe extends c{constructor({hash:e,version:t}){super(`Versioned hash "${e}" version is invalid.`,{metaMessages:["Expected: 1",`Received: ${t}`],name:"InvalidVersionedHashVersionError"})}}function Ze(e){const{data:t,kzg:a,to:r}=e,s=e.blobs??function(e){const t=e.to??("string"==typeof e.data?"hex":"bytes"),a="string"==typeof e.data?T(e.data):e.data,r=u(a);if(!r)throw new je;if(r>Ke)throw new Xe({maxSize:Ke,size:r});const s=[];let n=!0,l=0;for(;n;){const e=ee(new Uint8Array(Ve));let t=0;for(;t<Re;){const r=a.slice(l,l+31);if(e.pushByte(0),e.pushBytes(r),r.length<31){e.pushByte(128),n=!1;break}t++,l+=31}s.push(e)}return"bytes"===t?s.map(e=>e.bytes):s.map(e=>E(e.bytes))}({data:t,to:r}),n=e.commitments??he({blobs:s,kzg:a,to:r}),l=e.proofs??be({blobs:s,commitments:n,kzg:a,to:r}),o=[];for(let e=0;e<s.length;e++)o.push({blob:s[e],commitment:n[e],proof:l[e]});return o}class We extends c{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class Je extends c{constructor({chainId:e}){super("number"==typeof e?`Chain ID "${e}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}class Ye extends c{constructor({cause:e,message:t}={}){const a=t?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${a?`with reason: ${a}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"})}}Object.defineProperty(Ye,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(Ye,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class Qe extends c{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${ce(t)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(Qe,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class _e extends c{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${ce(t)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(_e,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class et extends c{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}is higher than the next one expected.`,{cause:e,name:"NonceTooHighError"})}}Object.defineProperty(et,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class tt extends c{constructor({cause:e,nonce:t}={}){super([`Nonce provided for the transaction ${t?`(${t}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join("\n"),{cause:e,name:"NonceTooLowError"})}}Object.defineProperty(tt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class at extends c{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(at,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class rt extends c{constructor({cause:e}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join("\n"),{cause:e,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(rt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class st extends c{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:e,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(st,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class nt extends c{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction is too low.`,{cause:e,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(nt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class lt extends c{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(lt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class ot extends c{constructor({cause:e,maxPriorityFeePerGas:t,maxFeePerGas:a}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${t?` = ${ce(t)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${a?` = ${ce(a)} gwei`:""}).`].join("\n"),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(ot,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});class ct extends c{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}class it extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=this.keys().next().value;e&&this.delete(e)}return this}}const pt=BigInt(0),dt=BigInt(1),mt=BigInt(2),ut=BigInt(7),ht=BigInt(256),bt=BigInt(113),xt=[],ft=[],yt=[];for(let e=0,t=dt,a=1,r=0;e<24;e++){[a,r]=[r,(2*a+3*r)%5],xt.push(2*(5*r+a)),ft.push((e+1)*(e+2)/2%64);let s=pt;for(let e=0;e<7;e++)t=(t<<dt^(t>>ut)*bt)%ht,t&mt&&(s^=dt<<(dt<<BigInt(e))-dt);yt.push(s)}const kt=function(e,t=!1){const a=e.length;let r=new Uint32Array(a),s=new Uint32Array(a);for(let n=0;n<a;n++){const{h:a,l:l}=Ie(e[n],t);[r[n],s[n]]=[a,l]}return[r,s]}(yt,!0),Et=kt[0],Ct=kt[1],vt=(e,t,a)=>a>32?((e,t,a)=>t<<a-32|e>>>64-a)(e,t,a):((e,t,a)=>e<<a|t>>>32-a)(e,t,a),wt=(e,t,a)=>a>32?((e,t,a)=>e<<a-32|t>>>64-a)(e,t,a):((e,t,a)=>t<<a|e>>>32-a)(e,t,a);class gt extends Ae{constructor(e,t,a,r=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=a,this.enableXOF=r,this.rounds=s,xe(a),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");var n;this.state=new Uint8Array(200),this.state32=(n=this.state,new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)))}clone(){return this._cloneInto()}keccak(){ge(this.state32),function(e,t=24){const a=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)a[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const r=(t+8)%10,s=(t+2)%10,n=a[s],l=a[s+1],o=vt(n,l,1)^a[r],c=wt(n,l,1)^a[r+1];for(let a=0;a<50;a+=10)e[t+a]^=o,e[t+a+1]^=c}let t=e[2],s=e[3];for(let a=0;a<24;a++){const r=ft[a],n=vt(t,s,r),l=wt(t,s,r),o=xt[a];t=e[o],s=e[o+1],e[o]=n,e[o+1]=l}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)a[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~a[(r+2)%10]&a[(r+4)%10]}e[0]^=Et[r],e[1]^=Ct[r]}Ee(a)}(this.state32,this.rounds),ge(this.state32),this.posOut=0,this.pos=0}update(e){ye(this),fe(e=Ue(e));const{blockLen:t,state:a}=this,r=e.length;for(let s=0;s<r;){const n=Math.min(t-this.pos,r-s);for(let t=0;t<n;t++)a[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:a,blockLen:r}=this;e[a]^=t,128&t&&a===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){ye(this,!1),fe(e),this.finish();const t=this.state,{blockLen:a}=this;for(let r=0,s=e.length;r<s;){this.posOut>=a&&this.keccak();const n=Math.min(a-this.posOut,s-r);e.set(t.subarray(this.posOut,this.posOut+n),r),this.posOut+=n,r+=n}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return xe(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ke(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Ee(this.state)}_cloneInto(e){const{blockLen:t,suffix:a,outputLen:r,rounds:s,enableXOF:n}=this;return e||(e=new gt(t,a,r,n,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=a,e.outputLen=r,e.enableXOF=n,e.destroyed=this.destroyed,e}}const Ut=(()=>{return e=1,t=136,a=32,Te(()=>new gt(t,e,a));var e,t,a})();const At=new it(8192);function Tt(e,t){if(At.has(`${e}.${t}`))return At.get(`${e}.${t}`);const a=e.substring(2).toLowerCase(),r=(s=B(a),Ut(m(s,{strict:!1})?g(s):s));var s;const n=a.split("");for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&n[e]&&(n[e]=n[e].toUpperCase()),(15&r[e>>1])>=8&&n[e+1]&&(n[e+1]=n[e+1].toUpperCase());const l=`0x${n.join("")}`;return At.set(`${e}.${t}`,l),l}const Bt=/^0x[a-fA-F0-9]{40}$/,St=new it(8192);function Ft(e,t){const{strict:a=!0}=t??{},r=`${e}.${a}`;if(St.has(r))return St.get(r);const s=!(!Bt.test(e)||e.toLowerCase()!==e&&a&&Tt(e)!==e);return St.set(r,s),s}function Dt(e,t,a,{strict:r}={}){return m(e,{strict:!1})?function(e,t,a,{strict:r}={}){const s=`0x${e.replace("0x","").slice(2*t,2*a)}`;r&&Pt(s,t,a);return s}(e,t,a,{strict:r}):function(e,t,a,{strict:r}={}){const s=e.slice(t,a);r&&Pt(s,t,a);return s}(e,t,a,{strict:r})}function Pt(e,t,a){if(u(e)!==a-t)throw new b({offset:a,position:"end",size:u(e)})}function zt(e){const{chainId:t,maxPriorityFeePerGas:a,maxFeePerGas:r,to:s}=e;if(t<=0)throw new Je({chainId:t});if(s&&!Ft(s))throw new We({address:s});if(r&&r>j)throw new Qe({maxFeePerGas:r});if(a&&r&&a>r)throw new ot({maxFeePerGas:r,maxPriorityFeePerGas:a})}function It(e){if(!e||0===e.length)return[];const t=[];for(let a=0;a<e.length;a++){const{address:r,storageKeys:s}=e[a];for(let e=0;e<s.length;e++)if(s[e].length-2!=64)throw new ue({storageKey:s[e]});if(!Ft(r,{strict:!1}))throw new We({address:r});t.push([r,s])}return t}function Mt(e,t){const a=function(e){if(e.type)return e.type;if(void 0!==e.authorizationList)return"eip7702";if(void 0!==e.blobs||void 0!==e.blobVersionedHashes||void 0!==e.maxFeePerBlobGas||void 0!==e.sidecars)return"eip4844";if(void 0!==e.maxFeePerGas||void 0!==e.maxPriorityFeePerGas)return"eip1559";if(void 0!==e.gasPrice)return void 0!==e.accessList?"eip2930":"legacy";throw new me({transaction:e})}(e);return"eip1559"===a?function(e,t){const{chainId:a,gas:r,nonce:s,to:n,value:l,maxFeePerGas:o,maxPriorityFeePerGas:c,accessList:i,data:p}=e;zt(e);const d=It(i),m=[C(a),s?C(s):"0x",c?C(c):"0x",o?C(o):"0x",r?C(r):"0x",n??"0x",l?C(l):"0x",p??"0x",d,...Lt(e,t)];return W(["0x02",te(m)])}(e,t):"eip2930"===a?function(e,t){const{chainId:a,gas:r,data:s,nonce:n,to:l,value:o,accessList:i,gasPrice:p}=e;!function(e){const{chainId:t,maxPriorityFeePerGas:a,gasPrice:r,maxFeePerGas:s,to:n}=e;if(t<=0)throw new Je({chainId:t});if(n&&!Ft(n))throw new We({address:n});if(a||s)throw new c("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(r&&r>j)throw new Qe({maxFeePerGas:r})}(e);const d=It(i),m=[C(a),n?C(n):"0x",p?C(p):"0x",r?C(r):"0x",l??"0x",o?C(o):"0x",s??"0x",d,...Lt(e,t)];return W(["0x01",te(m)])}(e,t):"eip4844"===a?function(e,t){const{chainId:a,gas:r,nonce:s,to:n,value:l,maxFeePerBlobGas:o,maxFeePerGas:c,maxPriorityFeePerGas:i,accessList:p,data:d}=e;!function(e){const{blobVersionedHashes:t}=e;if(t){if(0===t.length)throw new je;for(const e of t){const t=u(e),a=D(Dt(e,0,1));if(32!==t)throw new $e({hash:e,size:t});if(1!==a)throw new qe({hash:e,version:a})}}zt(e)}(e);let m=e.blobVersionedHashes,h=e.sidecars;if(e.blobs&&(void 0===m||void 0===h)){const t="string"==typeof e.blobs[0]?e.blobs:e.blobs.map(e=>E(e)),a=e.kzg,r=he({blobs:t,kzg:a});if(void 0===m&&(m=function(e){const{commitments:t,version:a}=e,r=e.to??("string"==typeof t[0]?"hex":"bytes"),s=[];for(const e of t)s.push(Ge({commitment:e,to:r,version:a}));return s}({commitments:r})),void 0===h){h=Ze({blobs:t,commitments:r,proofs:be({blobs:t,commitments:r,kzg:a})})}}const b=It(p),x=[C(a),s?C(s):"0x",i?C(i):"0x",c?C(c):"0x",r?C(r):"0x",n??"0x",l?C(l):"0x",d??"0x",b,o?C(o):"0x",m??[],...Lt(e,t)],f=[],y=[],k=[];if(h)for(let e=0;e<h.length;e++){const{blob:t,commitment:a,proof:r}=h[e];f.push(t),y.push(a),k.push(r)}return W(["0x03",te(h?[x,f,y,k]:x)])}(e,t):"eip7702"===a?function(e,t){const{authorizationList:a,chainId:r,gas:s,nonce:n,to:l,value:o,maxFeePerGas:c,maxPriorityFeePerGas:i,accessList:p,data:d}=e;!function(e){const{authorizationList:t}=e;if(t)for(const e of t){const{chainId:t}=e,a=e.address;if(!Ft(a))throw new We({address:a});if(t<0)throw new Je({chainId:t})}zt(e)}(e);const m=It(p),u=function(e){if(!e||0===e.length)return[];const t=[];for(const a of e){const{chainId:e,nonce:r,...s}=a,n=a.address;t.push([e?k(e):"0x",n,r?k(r):"0x",...Lt({},s)])}return t}(a);return W(["0x04",te([C(r),n?C(n):"0x",i?C(i):"0x",c?C(c):"0x",s?C(s):"0x",l??"0x",o?C(o):"0x",d??"0x",m,u,...Lt(e,t)])])}(e,t):function(e,t){const{chainId:a=0,gas:r,data:s,nonce:n,to:l,value:o,gasPrice:i}=e;!function(e){const{chainId:t,maxPriorityFeePerGas:a,gasPrice:r,maxFeePerGas:s,to:n}=e;if(n&&!Ft(n))throw new We({address:n});if(void 0!==t&&t<=0)throw new Je({chainId:t});if(a||s)throw new c("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(r&&r>j)throw new Qe({maxFeePerGas:r})}(e);let p=[n?C(n):"0x",i?C(i):"0x",r?C(r):"0x",l??"0x",o?C(o):"0x",s??"0x"];if(t){const e=(()=>{if(t.v>=35n){return(t.v-35n)/2n>0?t.v:27n+(35n===t.v?0n:1n)}if(a>0)return BigInt(2*a)+BigInt(35n+t.v-27n);const e=27n+(27n===t.v?0n:1n);if(t.v!==e)throw new de({v:t.v});return e})(),r=h(t.r),s=h(t.s);p=[...p,C(e),"0x00"===r?"0x":r,"0x00"===s?"0x":s]}else a>0&&(p=[...p,C(a),"0x","0x"]);return te(p)}(e,t)}function Lt(e,t){const a=t??e,{v:r,yParity:s}=a;if(void 0===a.r)return[];if(void 0===a.s)return[];if(void 0===r&&void 0===s)return[];const n=h(a.r),l=h(a.s);return["number"==typeof s?s?C(1):"0x":0n===r?"0x":1n===r?C(1):27n===r?"0x":C(1),"0x00"===n?"0x":n,"0x00"===l?"0x":l]}class Ot extends c{constructor(){super(["Transaction is not an EIP712 transaction.","","Transaction must:",' - include `type: "eip712"`'," - include one of the following: `customSignature`, `paymaster`, `paymasterInput`, `gasPerPubdata`, `factoryDeps`"].join("\n"),{name:"InvalidEip712TransactionError"})}}function Ht(e){return"eip712"===e.type||!!("customSignature"in e&&e.customSignature||"paymaster"in e&&e.paymaster||"paymasterInput"in e&&e.paymasterInput||"gasPerPubdata"in e&&"bigint"==typeof e.gasPerPubdata||"factoryDeps"in e&&e.factoryDeps)}function Nt(e){const{chainId:t,to:a,from:r,paymaster:s,paymasterInput:n}=e;if(!Ht(e))throw new Ot;if(!t||t<=0)throw new Je({chainId:t});if(a&&!Ft(a))throw new We({address:a});if(r&&!Ft(r))throw new We({address:r});if(s&&!Ft(s))throw new We({address:s});if(s&&!n)throw new c("`paymasterInput` must be provided when `paymaster` is defined");if(!s&&n)throw new c("`paymaster` must be provided when `paymasterInput` is defined")}const Gt={transaction:function(e,t){return Ht(e)?function(e){const{chainId:t,gas:a,nonce:r,to:s,from:n,value:l,maxFeePerGas:o,maxPriorityFeePerGas:c,customSignature:i,factoryDeps:p,paymaster:d,paymasterInput:m,gasPerPubdata:u,data:h}=e;Nt(e);return W(["0x71",te([r?k(r):"0x",c?k(c):"0x",o?k(o):"0x",a?k(a):"0x",s??"0x",l?k(l):"0x",h??"0x",k(t),k(""),k(""),k(t),n??"0x",k(u||$),p??[],i??"0x",d&&m?[d,m]:[]])])}(e):Mt(e,t)}};class Rt extends c{constructor({givenLength:e,maxBytecodeSize:t}){super(`Bytecode cannot be longer than ${t} bytes. Given length: ${e}`,{name:"BytecodeLengthExceedsMaxSizeError"})}}class Vt extends c{constructor({givenLengthInWords:e}){super(`Bytecode length in 32-byte words must be odd. Given length in words: ${e}`,{name:"BytecodeLengthInWordsMustBeOddError"})}}class Kt extends c{constructor({givenLength:e}){super(`The bytecode length in bytes must be divisible by 32. Given length: ${e}`,{name:"BytecodeLengthMustBeDivisibleBy32Error"})}}const Xt={blockTime:1e3,formatters:Z,serializers:Gt,custom:{getEip712Domain:e=>{Nt(e);const t=function(e){const{gas:t,nonce:a,to:r,from:s,value:n,maxFeePerGas:l,maxPriorityFeePerGas:o,factoryDeps:c,paymaster:i,paymasterInput:p,gasPerPubdata:d,data:m}=e;return{txType:113n,from:BigInt(s),to:r?BigInt(r):0n,gasLimit:t??0n,gasPerPubdataByteLimit:d??$,maxFeePerGas:l??0n,maxPriorityFeePerGas:o??0n,paymaster:i?BigInt(i):0n,nonce:a?BigInt(a):0n,value:n??0n,data:m??"0x",factoryDeps:c?.map(e=>k(function(e){const t=g(e);if(t.length%32!=0)throw new Kt({givenLength:t.length});if(t.length>q)throw new Rt({givenLength:t.length,maxBytecodeSize:q});const a=g(Ne(t)),r=t.length/32;if(r%2==0)throw new Vt({givenLengthInWords:r});const s=f(g(r),{size:2}),n=new Uint8Array([1,0]);return a.set(n,0),a.set(s,2),a}(e)))??[],paymasterInput:p||"0x"}}(e);return{domain:{name:"zkSync",version:"2",chainId:e.chainId},types:{Transaction:[{name:"txType",type:"uint256"},{name:"from",type:"uint256"},{name:"to",type:"uint256"},{name:"gasLimit",type:"uint256"},{name:"gasPerPubdataByteLimit",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymaster",type:"uint256"},{name:"nonce",type:"uint256"},{name:"value",type:"uint256"},{name:"data",type:"bytes"},{name:"factoryDeps",type:"bytes32[]"},{name:"paymasterInput",type:"bytes"}]},primaryType:"Transaction",message:t}}}},jt=t({...Xt,id:2741,name:"Abstract",nativeCurrency:{decimals:18,name:"ETH",symbol:"ETH"},rpcUrls:{default:{http:["https://api.mainnet.abs.xyz"],webSocket:["wss://api.mainnet.abs.xyz/ws"]}},blockExplorers:{default:{name:"Etherscan",url:"https://abscan.org"},native:{name:"Abstract Explorer",url:"https://explorer.mainnet.abs.xyz"}},contracts:{multicall3:{address:"0xAa4De41dba0Ca5dCBb288b7cC6b708F3aaC759E7",blockCreated:5288},erc6492Verifier:{address:"0xfB688330379976DA81eB64Fe4BF50d7401763B9C",blockCreated:5263}}}),$t=t({...Xt,id:11124,name:"Abstract Testnet",nativeCurrency:{decimals:18,name:"ETH",symbol:"ETH"},rpcUrls:{default:{http:["https://api.testnet.abs.xyz"]}},blockExplorers:{default:{name:"Etherscan",url:"https://sepolia.abscan.org"},native:{name:"Abstract Explorer",url:"https://explorer.testnet.abs.xyz"}},testnet:!0,contracts:{multicall3:{address:"0xF9cda624FBC7e059355ce98a31693d299FACd963",blockCreated:358349},erc6492Verifier:{address:"0xfB688330379976DA81eB64Fe4BF50d7401763B9C",blockCreated:431682}}}),qt=t({id:787,name:"Acala",network:"acala",nativeCurrency:{name:"Acala",symbol:"ACA",decimals:18},rpcUrls:{default:{http:["https://eth-rpc-acala.aca-api.network"],webSocket:["wss://eth-rpc-acala.aca-api.network"]}},blockExplorers:{default:{name:"Acala Blockscout",url:"https://blockscout.acala.network",apiUrl:"https://blockscout.acala.network/api"}},testnet:!1}),Zt=t({id:47,name:"Acria IntelliChain",nativeCurrency:{decimals:18,name:"ACRIA",symbol:"ACRIA"},rpcUrls:{default:{http:["https://aic.acria.ai"]}},blockExplorers:{default:{name:"Acria Explorer",url:"https://explorer.acria.ai"}},testnet:!1}),Wt=t({id:1215,name:"ADF Chain",nativeCurrency:{name:"ADDFILL",symbol:"ADF",decimals:18},rpcUrls:{default:{http:["https://mainnet.adftechnology.com"]}},blockExplorers:{default:{name:"ADF Mainnet Explorer",url:"https://explorer.adftechnology.com"}},testnet:!1}),Jt=t({id:168,name:"AIOZ Network",nativeCurrency:{decimals:18,name:"AIOZ",symbol:"AIOZ"},rpcUrls:{default:{http:["https://eth-dataseed.aioz.network"]}},blockExplorers:{default:{name:"AIOZ Explorer",url:"https://explorer.aioz.network"}},testnet:!1}),Yt=t({id:41455,name:"Aleph Zero",nativeCurrency:{name:"Aleph Zero",symbol:"AZERO",decimals:18},rpcUrls:{default:{http:["https://rpc.alephzero.raas.gelato.cloud"]}},blockExplorers:{default:{name:"Aleph Zero EVM Explorer",url:"https://evm-explorer.alephzero.org",apiUrl:"https://evm-explorer.alephzero.org/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:4603377}}}),Qt=t({id:2039,name:"Aleph Zero Testnet",nativeCurrency:{name:"TZERO",symbol:"TZERO",decimals:18},rpcUrls:{default:{http:["https://rpc.alephzero-testnet.gelato.digital"],webSocket:["wss://ws.alephzero-testnet.gelato.digital"]}},blockExplorers:{default:{name:"Aleph Zero EVM Testnet explorer",url:"https://evm-explorer-testnet.alephzero.org",apiUrl:"https://evm-explorer-testnet.alephzero.org/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:2861745}},testnet:!0}),_t=t({id:10241024,name:"AlienX Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.alienxchain.io/http"]}},blockExplorers:{default:{name:"AlienX Explorer",url:"https://explorer.alienxchain.io"}},testnet:!1}),ea=t({id:10241025,name:"ALIENX Hal Testnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://hal-rpc.alienxchain.io/http"]}},blockExplorers:{default:{name:"AlienX Explorer",url:"https://hal-explorer.alienxchain.io"}},testnet:!0}),ta={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}},aa={block:O({format(e){const t=e.transactions?.map(e=>{if("string"==typeof e)return e;const t=I(e);return"0x7e"===t.typeHex&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?F(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t});return{transactions:t,stateRoot:e.stateRoot}}}),transaction:M({format(e){const t={};return"0x7e"===e.type&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?F(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:R({format:e=>({l1GasPrice:e.l1GasPrice?F(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?F(e.l1GasUsed):null,l1Fee:e.l1Fee?F(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null})})};function ra(e,t){return function(e){return"deposit"===e.type||void 0!==e.sourceHash}(e)?function(e){!function(e){const{from:t,to:a}=e;if(t&&!Ft(t))throw new We({address:t});if(a&&!Ft(a))throw new We({address:a})}(e);const{sourceHash:t,data:a,from:r,gas:s,isSystemTx:n,mint:l,to:o,value:c}=e,i=[t,r,o??"0x",l?k(l):"0x",c?k(c):"0x",s?k(s):"0x",n?"0x1":"0x",a??"0x"];return W(["0x7e",te(i)])}(e):Mt(e,t)}const sa={blockTime:2e3,contracts:ta,formatters:aa,serializers:{transaction:ra}},na=1,la=t({...sa,id:888888888,name:"Ancient8",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.ancient8.gg"]}},blockExplorers:{default:{name:"Ancient8 explorer",url:"https://scan.ancient8.gg",apiUrl:"https://scan.ancient8.gg/api"}},contracts:{...sa.contracts,l2OutputOracle:{[na]:{address:"0xB09DC08428C8b4EFB4ff9C0827386CDF34277996"}},portal:{[na]:{address:"0x639F2AECE398Aa76b07e59eF6abe2cFe32bacb68",blockCreated:19070571}},l1StandardBridge:{[na]:{address:"0xd5e3eDf5b68135D559D572E26bF863FBC1950033",blockCreated:19070571}}},sourceId:1}),oa=11155111,ca=t({...sa,id:28122024,name:"Ancient8 Testnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpcv2-testnet.ancient8.gg"]}},blockExplorers:{default:{name:"Ancient8 Celestia Testnet explorer",url:"https://scanv2-testnet.ancient8.gg",apiUrl:"https://scanv2-testnet.ancient8.gg/api"}},contracts:{...sa.contracts,l2OutputOracle:{[oa]:{address:"0x942fD5017c0F60575930D8574Eaca13BEcD6e1bB"}},portal:{[oa]:{address:"0xfa1d9E26A6aCD7b22115D27572c1221B9803c960",blockCreated:4972908}}