Ethereum TS
@krzkaczor
Organization overview
TypeScript = JavaScript + types
function sum(a, b) {
return a + b;
}
const four = sum(2,2);
function sum(a: number, b: number) {
return a + b;
}
const four = sum(2,2);
vs
TS's type system:
- structural typing
- advanced type level features (conditional types, mapped types)
- entirely stripped out from the output
- allows advanced refactoring
ethereum-ts
Ethereum TS
ethereum_ts
Ethereum related tools build for TypeScript
TypeChain
🔌 TypeScript bindings for Ethereum smart contracts
ABI -> TS Typings
[
...
{
constant: true,
inputs: [{ name: "offset", type: "uint256" }],
name: "getCounter",
outputs: [{ name: "", type: "uint256" }],
payable: false,
stateMutability: "view",
type: "function",
},
...
]
export class ContractWithOverloads {
// ...
methods: {
getCounter(offset: number | string)
: TransactionObject<string>;
// ...
}
}
Multiple targets🎯
- web3 0.20.x
- web3 1.0.0
- truffle 4.x (5.x support coming!)
- ethers.js
Architecture
ts-generator
ABI parser
user config
web3 target
truffle target
ethers.js target
your target
/contracts/**/*.abi
krzkaczor/ts-generator
- ~400 GH STARS 🌟
- more than 10 contributors
- multiple blockchain companies using it: Market Protocol, Plasma MVP, dxdy ...
- around 1k DAI in bounties via GitCoin
Stats
evm-ts
Ethereum Virtual Machine implemented in TypeScript
solidity -> bytecode -> VM
0x600015
60 00 15
PUSH1 00 ISZERO
Bytecode decoding
PUSH1
00
ISZERO
Bytecode execution
-
Stack
Program
PUSH1
00
ISZERO
00
Stack
Program
PUSH1
00
ISZERO
01
Stack
Program
Takeaways
EVM was built by cryptographers
- 256 bits words
- SHA3 opcode
- lack of static JUMPS
- tangled with blockchain
CALL, DELEGATECALL, CALLCODE etc
- can be implemented by one generic function
- tx can be partially rejected
Gas estimations are not trivial
- GAS opcode returns gas left
Opcodes can be implemented as classes
(but probably shouldn't be)
Tests against other VMs are awesome
Read more:
- DEVCON 4 EVM 2.0
- https://badootech.badoo.com/when-pigs-fly-optimising-bytecode-interpreters-f64fb6bfa20f
-
Meta
- sponsors infra projects via money from ECF
- companies sponsor projects that they use
Ethereum JS collaboration
THANKS!
https://github.com/ethereum-ts
@krzkaczor
Ethereum TS — Organization overview
By krzkaczor
Ethereum TS — Organization overview
- 487