当我们进行任何交易时,我们需要每笔交易的gas,所以我修复了多少gas才能进行成功的交易,因为有时交易成功,有时它会给我一个错误:
错误:返回错误:天然气 * 价格 + 价值的资金不足
exports.sendTransactions = (sender_account, to_account, p_key, value ) => {
console.log("sendTRansactions", sender_account, to_account , p_key , value );
var admin = sender_account;
var contract_address = to_account;
var tx = {
from: admin,
to: contract_address,
gas: 184000,
data: "",
value: value
};
return web3.eth.accounts.signTransaction(tx, p_key).then((hash) => {
return web3.eth.sendSignedTransaction(hash.rawTransaction).then((receipt) => {
return receipt
}, (error) => {
return error
console.log(error);
// reject(500);
})
}, (error) => {
return error
// reject(500);
});
}
我刚刚在字符串示例中制作了气体: 气体:"184000",
它对我有用。