Skip to content

Add catch contract feature

Add catch contract feature. It depends on auth smart contract update with ability to emit event in constructor;

To filter all authentificator smart contracts:

var CurrFilterRes; web3.eth.filter({fromBlock: 0, toBlock: 'latest', topics: [web3.sha3('PheixAuthCode(uint256)'),"0x" + web3.padLeft('1',64)]}).get(function(error, result){ if (!error) CurrFilterRes = result; else console.log(error); });

The CurrFilterRes will contain array with smart contract details (address is smart contract deployment addr, get the latest with CurrFilterRes[CurrFilterRes.length - 1]):

[{
    address: "0x78d8183710ecbb204e2f0220d24110d97cd36ea8",
    blockHash: "0x0860e9cd3638bbfb478bfc8b3b2938021d1d2ca1eecf8c2db1afb0c5be8f5591",
    blockNumber: 25,
    data: "0x",
    logIndex: 0,
    removed: false,
    topics: ["0x1afba253d16484eec92f8931ecedf989ad94e32e0a097a8b37c174c1c86524d4", "0x0000000000000000000000000000000000000000000000000000000000000001"],
    transactionHash: "0xd9d60c2379892dcad6a937ed34b1dc2544a56c98d93130dc9260f4c3b5937329",
    transactionIndex: 0
}, {
    address: "0x92f2d25504ef38ee3c9cdabde6e309a061c67e20",
    blockHash: "0x3ce94da169a7761c5a98a5307f621bd826a658057f13926f9ca076c35655db7a",
    blockNumber: 468,
    data: "0x",
    logIndex: 0,
    removed: false,
    topics: ["0x1afba253d16484eec92f8931ecedf989ad94e32e0a097a8b37c174c1c86524d4", "0x0000000000000000000000000000000000000000000000000000000000000001"],
    transactionHash: "0x091f999c716296c5ae28cfbf15cb5e96fae12003b0b88bc05c405ffea9ff6199",
    transactionIndex: 0
}]

The catch contract feature just should:

  • Get latest deployed smart contract
  • Get latest updateState() transaction for this smart contract (CurrFilterRes[CurrFilterRes.length - 1]):
var CurrFilterRes; web3.eth.filter({fromBlock: 468, toBlock: 'latest', address: '0x92f2d25504ef38ee3c9cdabde6e309a061c67e20', topics: [web3.sha3('PheixAuthCode(uint256)'),"0x" + web3.padLeft('2',64)]}).get(function(error, result){ if (!error) CurrFilterRes = result; else console.log(error); });
  • Try to validate session with validate_on_blockchain() use the transaction hash from previous step.
Edited by Konstantin Narkhov