{"id":2207,"date":"2022-05-03T14:06:50","date_gmt":"2022-05-03T05:06:50","guid":{"rendered":"https:\/\/blog.wsd.sh\/?p=2207"},"modified":"2022-10-20T04:40:53","modified_gmt":"2022-10-19T19:40:53","slug":"contract%e3%81%ab%e5%bf%85%e8%a6%81%e3%81%aagas","status":"publish","type":"post","link":"https:\/\/blog.wsd.sh\/?p=2207","title":{"rendered":"<small>sendTransaction (\u9001\u91d1)\u306b\u5fc5\u8981\u306aGas\u4ee3\uff08\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u624b\u6570\u6599\uff09<\/small>"},"content":{"rendered":"<p>\uff11\uff0esendTransaction \u306b\u5fc5\u8981\u306aGas(\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u624b\u6570\u6599)<br \/>\nETH\u306e\u9001\u91d1\u3084\u30b9\u30de\u30fc\u30c8\u30b3\u30f3\u30c8\u30e9\u30af\u30c8\u5b9f\u884c\u306e\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u627f\u8a8d\u624b\u6570\u6599<\/p>\n<p>EIP-1559\u3067\u3001\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u30ac\u30b9\u624b\u6570\u6599\u306e\u30e1\u30ab\u30cb\u30ba\u30e0\u304c\u5909\u66f4\u306b\u306a\u3063\u305f<\/p>\n<p>\u56fa\u5b9a\u4fa1\u683c\u30bb\u30fc\u30eb\uff08fixed-price sale\uff09\u306b\u7f6e\u304d\u63db\u3048<\/p>\n<p>\uff12\uff0e\u4ee5\u524d\u306eGas \u4ee3<br \/>\nGas\u4ee3\uff08\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u624b\u6570\u6599\uff09 = gas \u00d7 gasPrice<br \/>\n(1) gas (\u30ac\u30b9\u91cf)<br \/>\n(2) gasPrice (\u30ac\u30b9\u4fa1\u683c)<\/p>\n<p>\u30fb\u30ac\u30b9\u30ea\u30df\u30c3\u30c8<br \/>\n\uff08Gas Limit\uff09\u3068\u306f\u3001\u53d6\u5f15\u3067\u8cbb\u3084\u3057\u3066\u3082\u3088\u3044\u624b\u6570\u6599\uff08Gas\uff09\u306e\u4e0a\u9650\u5024\u200b<br \/>\n\u9001\u91d1\u624b\u6570\u6599\u306e\u6700\u5927\u5024 = \u30ac\u30b9\u4fa1\u683c \u00d7 \u30ac\u30b9\u30ea\u30df\u30c3\u30c8<\/p>\n<p>\uff13\uff0eEIP-1559<\/p>\n<p> transaction fee : Gas units (limit) * (Base fee + Tip)<\/p>\n<p>Gas Price\u306e\u4ee3\u308f\u308a\u306b\u3001<br \/>\nGas units (limit) * (Base fee + Tip)<br \/>\n\u30fbBase Fee Per Gas\u3000(Base Fee)\u3000\u3000\uff1a\u30d6\u30ed\u30c3\u30af\u6bce\u306b\u56fa\u5b9a<br \/>\n\u30fbPriority Fee Per Gas (Tip)   \u3000 \u3000\u3000\u3000\uff1a\u30c1\u30c3\u30d7<br \/>\n\u30fbMax Fee Per Gas (maxFeePerGas) \uff1a\u30d6\u30ed\u30c3\u30af\u306b\u542b\u3081\u308b\u305f\u3081\u306b\u51fa\u305b\u308b\u6700\u5927\u984d<\/p>\n<p>\uff14\uff0e\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u306eType 2\u3067\u30ac\u30b9\u624b\u6570\u6599\u3092\u8a08\u7b97<br \/>\n\uff08\uff11\uff09Base Fee Per Gas + Priority Fee Per Gas > Max Fee Per Gas\u306e\u5834\u5408<br \/>\n\u30fb\u6700\u5927\u624b\u6570\u6599<br \/>\n\u624b\u6570\u6599 =  (gas limit) * (maxFeePerGas)<\/p>\n<p>\uff08\uff12\uff09Base Fee Per Gas + Priority Fee Per Gas &lt;= Max Fee Per Gas\u306e\u5834\u5408<br \/>\n\u30fb\u901a\u5e38\u306e\u624b\u6570\u6599<br \/>\n\u624b\u6570\u6599 = (Gas) * (base fee + priority fee)<\/p>\n<p>\uff15\uff0eweb3.eth\u3000method<br \/>\n(1)  estimateGas\uff1a<br \/>\n estimateGas = web3.eth.estimateGas(callObject )<\/p>\n<p>(2)  getGasPrice:<br \/>\n gasPrice = web3.eth.getGasPrice() ;<\/p>\n<p>(3) gasLimit<br \/>\ngasLimit = web3.utils.toHex(22000);<\/p>\n<p>\uff16\uff0e\u8ffd\u52a0<br \/>\n\u30fbgetFeeHistory<br \/>\nestimateGas\u306e\u4ee3\u308f\u308a<br \/>\nweb3.eth.getFeeHistory(blockCount, newestBlock, rewardPercentiles, [callback])<\/p>\n<p>\u30fbmaxPriorityFeePerGas<br \/>\nweb3.eth.getMaxPriorityFeePerGas()<br \/>\n\u30fbmaxFeePerGas<\/p>\n<p>\uff17\uff0e\u73fe\u5728\u3000\u306e\u52d5\u4f5c\u78ba\u8a8d<br \/>\nganache\u306flocal\u3067\u52d5\u304b\u3057\u3066\u3044\u308b\u305b\u3044\u304bweb3.eth.getFeeHistory()\u306ferror\u306b\u306a\u308b<\/p>\n<pre>\r\n The method eth_feeHistory does not exist\/is not available\r\n<\/pre>\n<p>geth\u304b\u3089\u3082\u30a2\u30af\u30bb\u30b9\u3067\u304d\u306a\u3044<\/p>\n<pre>\r\n> eth.getFeeHistory(4, \"latest\")\r\nTypeError: 'getFeeHistory' is not a function\r\n    at <anonymous>:1:1\r\n\r\n>\r\n<\/pre>\n<p>\uff18\uff0ereceipt\u306beffectiveGasPrice\u304c\u8ffd\u52a0<\/p>\n<pre>\r\n\u30fbPre-London\u3067\u306f\u3001\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u306egasPrice\u3068\u540c\u3058\r\n\u30fbeffectiveGasPrice\u306f\u30ed\u30f3\u30c9\u30f3\u5f8c\u3001\u652f\u6255\u308f\u308c\u305f\u5b9f\u969b\u306e\u30ac\u30b9\u4fa1\u683c\u306b\u7b49\u3057\u3044\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\uff11\uff0esendTransaction \u306b\u5fc5\u8981\u306aGas(\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u624b\u6570\u6599) ETH\u306e\u9001\u91d1\u3084\u30b9\u30de\u30fc\u30c8\u30b3\u30f3\u30c8\u30e9\u30af\u30c8\u5b9f\u884c\u306e\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u627f\u8a8d\u624b\u6570\u6599 EIP-1559\u3067\u3001\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u30ac\u30b9\u624b\u6570\u6599\u306e\u30e1\u30ab\u30cb\u30ba\u30e0\u304c\u5909\u66f4\u306b\u306a\u3063\u305f &#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts\/2207"}],"collection":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2207"}],"version-history":[{"count":38,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts\/2207\/revisions"}],"predecessor-version":[{"id":2261,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts\/2207\/revisions\/2261"}],"wp:attachment":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}