Contract-Development

交易中如何計算 ETH 的兌換費?

  • February 17, 2018

假設我有以下解碼的交易輸入數據:

[
 "0x0000000000000000000000000000000000000000",
 "690000000000000000",
 "0xac709fcb44a43c35f0da4e3163b117a17f3770f5",
 "69000000000000000000",
 "3157593",
 "3268274872",
 "0x7d7a96a720396bb22681578545c56899f23f58e3",
 "27",
 "bdc6f8d14ade98f529d06fa1b1e85a9deb19df7a1621cc561a5167286d143885",
 "74e1206d9bdd7e39fad74991ad630fc424af1e34bf3c788aa22ac505804b9bd5",
 "100000000000000000"
]

在這個智能合約trade的方法中使用。

在此呼叫中,發送者願意通過出售購買ARC( 0xac709fcb44a43c35f0da4e3163b117a17f3770f5 ) 代幣ETH

我要計算的是ETH要發送多少feeAccount這行程式碼

tokens[tokenGet][feeAccount] = safeAdd(tokens[tokenGet][feeAccount], safeSub(safeAdd(feeMakeXfer, feeTakeXfer), feeRebateXfer));

我的計算是:

const web3 = require('web3');

const feeMake = '0';
const feeTake = '3000000000000000';

let feeMakeXfer = (100000000000000000 * feeMake) / web3.utils.toWei('1', 'ether'); // 0
let feeTakeXfer = (100000000000000000 * feeTake) / web3.utils.toWei('1', 'ether')); // 300000000000000
let feeRebateXfer = 0;

let accountFee = feeMakeXfer + feeTakeXfer - feeRebateXfer; // 0.0003 ETH

所以根據我的計算,這筆交易的賬戶費用是0.0003 ETH

這是正確的嗎?

是的,你的計算看起來又正確了。

引用自:https://ethereum.stackexchange.com/questions/40000