Skip to content

Instantly share code, notes, and snippets.

@Brunya
Created March 10, 2021 09:21
Show Gist options
  • Select an option

  • Save Brunya/5f3581fbb5821742404d6a6d6809ed7a to your computer and use it in GitHub Desktop.

Select an option

Save Brunya/5f3581fbb5821742404d6a6d6809ed7a to your computer and use it in GitHub Desktop.
ZGEN coding test

Senior Rust coding test

The motivation behind the coding test is the measurement of the qualification and testing the learning attitude of the candidate.

Task

Create a simple ABI parser library. Please do NOT use any library you can find on the internet only certain exceptions detailed later.

  • Rust

Details

  • The library should accept a file (contains the abi of an Ethereum based smart contract), and a function signature with parameters depends on necessity.
  • The library should NOT use any external library except the one responsible for keccak256 hashing.
  • The library should be as simple as possible so the user doesn’t have pray for the undefined gods to make it work.

Test-cases

The ABI file will be provided which should satisfy the following test scenarios:

Function name Parameters Result transaction data
balanceOf [0x30E7d7FfF85C8d0E775140b1aD93C230D5595207] 0x70a0823100000000000000000000000030e7d7fff85c8d0e775140b1ad93c230d5595207
transfer [0x30E7d7FfF85C8d0E775140b1aD93C230D5595207, 20000000000] 0xa9059cbb00000000000000000000000030e7d7fff85c8d0e775140b1ad93c230d559520700000000000000000000000000000000000000000000000000000004a817c800
allowance [0x30E7d7FfF85C8d0E775140b1aD93C230D5595207, 0x81Fbae3C693624FEc9eF1a86626228980bEB1C71] 0xdd62ed3e00000000000000000000000030e7d7fff85c8d0e775140b1ad93c230d559520700000000000000000000000081fbae3c693624fec9ef1a86626228980beb1c71
  • So it should accept the function name and the parameters and should return the Transaction data.
  • If the candidate familiar with Solidity the library can return whether it should be an eth_call or an eth_sendTransaction next to the data.

Any other information should be researched by the candidate. In case of questions please contact us.

Links

Note

  • senior_rust_abi.json should be contained.
[
{
"constant": true,
"inputs": [],
"name": "name",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_spender",
"type": "address"
},
{
"name": "_value",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_from",
"type": "address"
},
{
"name": "_to",
"type": "address"
},
{
"name": "_value",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "decimals",
"outputs": [
{
"name": "",
"type": "uint8"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_owner",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"name": "balance",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "symbol",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_to",
"type": "address"
},
{
"name": "_value",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_owner",
"type": "address"
},
{
"name": "_spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"payable": true,
"stateMutability": "payable",
"type": "fallback"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "owner",
"type": "address"
},
{
"indexed": true,
"name": "spender",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "from",
"type": "address"
},
{
"indexed": true,
"name": "to",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment