Skip to main content

here is my soliditySolidity snippet:

function deliverPrizes(address payable winner) public onlyOwner{ 
    winner.transfer(address(this).balance);
}

This is what I wrote on truffle console:

dCoders.deployed().then((i)=>{return
     return
         i.deliverPrizes.sendTransaction('0xd2Bd7C19D539c2F080f70Db89f6a
345f6673Abe6''0xd2Bd7C19D539c2F080f70Db89f6a345f6673Abe6',
         {from:'0xF198c57CEfD8899Fb0759883B2b1Aa041E0dD599'}) 
})

But the transaction is: { tx: '0xffde0828da8362ed214df1dc75fdcbc279ccdcdbfaf8aa06d7341fc6b98a58a6', receipt: { transactionHash: '0xffde0828da8362ed214df1dc75fdcbc279ccdcdbfaf8aa06d7341fc6b98a58a6', transactionIndex: 0, blockHash: '0x25e86d226fec25db3ed06b2a57943a03931e213d9180e90cfd8ad54e60a84a3f', blockNumber: 34, from: '0x0d67e3546769b104b67cb719427e9c79b3fb3bcf', to: '0xf198c57cefd8899fb0759883b2b1aa041e0dd599', gasUsed: 29513, cumulativeGasUsed: 29513, contractAddress: null, logs: [], status: true, logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000800000000000000000000000000000000000000000000000000000000000000000400000000080000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000002000000000000000000000000', v: '0x1c', r: '0x6b260f24839b98cccf459c20a6f3d5e92ca3208db97ad44370ea9afceb5307da', s: '0x6200005b196f2da06d1cc4d2f91447133b7f7a9ac671a9be54c21e635e7bd59c', rawLogs: [ [Object] ] }, logs: [] }

{ tx: '0xffde0828da8362ed214df1dc75fdcbc279ccdcdbfaf8aa06d7341fc6b98a58a6',
    receipt:
    { 
        transactionHash: '0xffde0828da8362ed214df1dc75fdcbc279ccdcdbfaf8aa06d7341fc6b98a58a6',
        transactionIndex: 0,
        blockHash:   '0x25e86d226fec25db3ed06b2a57943a03931e213d9180e90cfd8ad54e60a84a3f',
        blockNumber: 34,
        from: '0x0d67e3546769b104b67cb719427e9c79b3fb3bcf',
        to: '0xf198c57cefd8899fb0759883b2b1aa041e0dd599',
        gasUsed: 29513,
        cumulativeGasUsed: 29513,
        contractAddress: null,
        logs: [],
        status: true,
        logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000800000000000000000000000000000000000000000000000000000000000000000400000000080000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000002000000000000000000000000',
        v: '0x1c',
        r: '0x6b260f24839b98cccf459c20a6f3d5e92ca3208db97ad44370ea9afceb5307da',
        s: '0x6200005b196f2da06d1cc4d2f91447133b7f7a9ac671a9be54c21e635e7bd59c',
        rawLogs: [ [Object] ] 
    },
logs: [] 
}

So it is from owner's account to winnerwinner's one, not from contract address and alsoaddress's one. Also no amount is being deducted from owner's account  ,that since the transaction only includes gas fee.

here is my solidity snippet:

function deliverPrizes(address payable winner) public onlyOwner{ 
winner.transfer(address(this).balance);
}

This is what I wrote on truffle console:

dCoders.deployed().then((i)=>{return 
i.deliverPrizes.sendTransaction('0xd2Bd7C19D539c2F080f70Db89f6a
345f6673Abe6',{from:'0xF198c57CEfD8899Fb0759883B2b1Aa041E0dD599'})})

But the transaction is: { tx: '0xffde0828da8362ed214df1dc75fdcbc279ccdcdbfaf8aa06d7341fc6b98a58a6', receipt: { transactionHash: '0xffde0828da8362ed214df1dc75fdcbc279ccdcdbfaf8aa06d7341fc6b98a58a6', transactionIndex: 0, blockHash: '0x25e86d226fec25db3ed06b2a57943a03931e213d9180e90cfd8ad54e60a84a3f', blockNumber: 34, from: '0x0d67e3546769b104b67cb719427e9c79b3fb3bcf', to: '0xf198c57cefd8899fb0759883b2b1aa041e0dd599', gasUsed: 29513, cumulativeGasUsed: 29513, contractAddress: null, logs: [], status: true, logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000800000000000000000000000000000000000000000000000000000000000000000400000000080000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000002000000000000000000000000', v: '0x1c', r: '0x6b260f24839b98cccf459c20a6f3d5e92ca3208db97ad44370ea9afceb5307da', s: '0x6200005b196f2da06d1cc4d2f91447133b7f7a9ac671a9be54c21e635e7bd59c', rawLogs: [ [Object] ] }, logs: [] }

So it is from owner's account to winner not from contract address and also no amount is being deducted from owner's account  ,that transaction only includes gas fee.

here is my Solidity snippet:

function deliverPrizes(address payable winner) public onlyOwner{ 
    winner.transfer(address(this).balance);
}

This is what I wrote on truffle console:

dCoders.deployed().then((i)=>{
     return
         i.deliverPrizes.sendTransaction('0xd2Bd7C19D539c2F080f70Db89f6a345f6673Abe6',
         {from:'0xF198c57CEfD8899Fb0759883B2b1Aa041E0dD599'}) 
})

But the transaction is:

{ tx: '0xffde0828da8362ed214df1dc75fdcbc279ccdcdbfaf8aa06d7341fc6b98a58a6',
    receipt:
    { 
        transactionHash: '0xffde0828da8362ed214df1dc75fdcbc279ccdcdbfaf8aa06d7341fc6b98a58a6',
        transactionIndex: 0,
        blockHash:   '0x25e86d226fec25db3ed06b2a57943a03931e213d9180e90cfd8ad54e60a84a3f',
        blockNumber: 34,
        from: '0x0d67e3546769b104b67cb719427e9c79b3fb3bcf',
        to: '0xf198c57cefd8899fb0759883b2b1aa041e0dd599',
        gasUsed: 29513,
        cumulativeGasUsed: 29513,
        contractAddress: null,
        logs: [],
        status: true,
        logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000800000000000000000000000000000000000000000000000000000000000000000400000000080000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000002000000000000000000000000',
        v: '0x1c',
        r: '0x6b260f24839b98cccf459c20a6f3d5e92ca3208db97ad44370ea9afceb5307da',
        s: '0x6200005b196f2da06d1cc4d2f91447133b7f7a9ac671a9be54c21e635e7bd59c',
        rawLogs: [ [Object] ] 
    },
logs: [] 
}

So it is from owner's account to winner's one, not from contract address's one. Also no amount is being deducted from owner's account, since the transaction only includes gas fee.

Source Link
Hrishabh
  • 71
  • 1
  • 7

Transferring ether balance from contract balance to winner,not working

here is my solidity snippet:

function deliverPrizes(address payable winner) public onlyOwner{ 
winner.transfer(address(this).balance);
}

This is what I wrote on truffle console:

dCoders.deployed().then((i)=>{return 
i.deliverPrizes.sendTransaction('0xd2Bd7C19D539c2F080f70Db89f6a
345f6673Abe6',{from:'0xF198c57CEfD8899Fb0759883B2b1Aa041E0dD599'})})

But the transaction is: { tx: '0xffde0828da8362ed214df1dc75fdcbc279ccdcdbfaf8aa06d7341fc6b98a58a6', receipt: { transactionHash: '0xffde0828da8362ed214df1dc75fdcbc279ccdcdbfaf8aa06d7341fc6b98a58a6', transactionIndex: 0, blockHash: '0x25e86d226fec25db3ed06b2a57943a03931e213d9180e90cfd8ad54e60a84a3f', blockNumber: 34, from: '0x0d67e3546769b104b67cb719427e9c79b3fb3bcf', to: '0xf198c57cefd8899fb0759883b2b1aa041e0dd599', gasUsed: 29513, cumulativeGasUsed: 29513, contractAddress: null, logs: [], status: true, logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000800000000000000000000000000000000000000000000000000000000000000000400000000080000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000002000000000000000000000000', v: '0x1c', r: '0x6b260f24839b98cccf459c20a6f3d5e92ca3208db97ad44370ea9afceb5307da', s: '0x6200005b196f2da06d1cc4d2f91447133b7f7a9ac671a9be54c21e635e7bd59c', rawLogs: [ [Object] ] }, logs: [] }

So it is from owner's account to winner not from contract address and also no amount is being deducted from owner's account ,that transaction only includes gas fee.