@krzkaczor
@ethereum_ts
~ some JS devs
class Cat extends Animal {
meow = async () => {
console.log("returned promise of moewing");
}
}
function main() {
const cat = new Cat();
cat.meow();
}
~ me
class Cat extends Animal {
meow = async () => {
console.log("returned promise of moewing");
}
}
function main() {
const cat = new Cat();
cat.meow(); // floating promise detected!
}
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:
const MyContract = web3.eth.contract(abiArray);
// instantiate by address
const contractInstance = MyContract.at(address);
// call
const result = await myContractInstance.myConstantMethod('myParam');
// tx
const resultTx = await myContractInstance.myStateChangingMethod('someParam1', 23,
{value: 200, gas: 2000});
Interacting with smart contracts using JS and Web3js
Typescript bindings for Ethereum smart contracts
ABI
=>
TS wrapper
ethereum-ts/TypeChain
@krzkaczor
https://github.com/ethereum-ts/TypeChain