GithubHelp home page GithubHelp logo

grashias / erc865-token-demo Goto Github PK

View Code? Open in Web Editor NEW
9.0 9.0 10.0 975 KB

ERC865 Token Demo - Gasless transaction (Delegate the payment of gas for token transfers)

CSS 12.86% HTML 52.43% JavaScript 34.71%

erc865-token-demo's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

erc865-token-demo's Issues

transferPresigned

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 ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.