grashias / erc865-token-demo Goto Github PK
View Code? Open in Web Editor NEWERC865 Token Demo - Gasless transaction (Delegate the payment of gas for token transfers)
ERC865 Token Demo - Gasless transaction (Delegate the payment of gas for token transfers)
Hi, I deploy a new token with your contract erc865, and i want to use web3js without metamask, i test your code with my ABI and ContractAddress, the transaction working nice with metamask, but without, i have an error on ertherscan...
I can have the hash with function recoverPreSignedHash and sign with web3.eth.accounts.sign with private key of signer(sender). I think the problem come from the transaction
`
var amount = web3.utils.toHex(1000000000000000000)
var fees = web3.utils.toHex(100000000000000000)
const privateKey1 = Buffer.from('private_key_deleguate', 'hex')
var gasPrice = '21000000000';
web3.eth.getTransactionCount(deleguate, (err, txCount) => {
if (err) {
console.error(err);
return err;
}
console.log(txCount)
// Build the transaction
const txObject = {
"chainId": 4,
"from": deleguate,
"nonce": web3.utils.toHex(txCount),
"gasPrice": web3.utils.toHex(gasPrice),
"gasLimit": web3.utils.toHex(800000),
"to": ContractAddress,
"value": "0x00",
"data":
//contract.methods.transfer(receiver, amount).encodeABI() ---> this work fine
contract.methods.transferPreSigned(signature, receiver, amount, fees, web3.utils.toHex(txCount)).encodeABI()
}
// Sign the transaction
const tx = new Tx(txObject)
tx.sign(privateKey1)
const raw = "0x" + tx.serialize().toString('hex');
web3.eth.sendSignedTransaction(raw, (err, result) => {
if (err) return console.error('error ', err);
console.log('send token hash Tx: ', result);
}).on('receipt', receipt => {
//console.log('------> ', receipt)
return { "code": 200, "message": "transfer token succeed", "address": receipt };
}).on('error -> ', error => {
console.error(userWallet, "Error send token ", error);
return { "code": 409, "error": "sign transaction error" };
});
`
This code give me a hash Tx etherscan like this: https://rinkeby.etherscan.io/tx/0x421b8bdc2bcdde652b0fb785221de51e0c93bd3c116fd0a39f4d7ab7966b3361
Does anybody have a help ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.