Skip to content

Instantly share code, notes, and snippets.

View firstprimecrypto's full-sized avatar

firstprimecrypto

View GitHub Profile
function swapETHToDai() public payable returns(uint[] memory) {
// static array: address[k] memory array;
// The following is the dynamic array way of initialization
address[] memory _paths = new address[](2);
// Also, push() is for storage array.
_paths[0] = WETHAddress;
_paths[1] = DaiAddress;
return uniswapV2Router01.swapExactETHForTokens{value: msg.value}(0, _paths, msg.sender, now + 120);
}