Categories
Cryptocurrency Ethereum Mastering Development

Public function when called from another contract throws error “The called function should be payable if you send value”?

This is the contract I am calling from: contract MultiTransfer { function multiTransfer(Marcelo token, address _addresses, uint256 amount) public { token.transfer(_addresses, amount); } } This the contract where the transfer function is: contract Marcelo is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address […]

Categories
Cryptocurrency Ethereum Mastering Development

Can’t estimate gas on Infura using web3 or axios

I’m trying to estimate gas required to transfer usdt using Infura node but always receive gas required exceeds allowance (12451164) or always failing transaction error. I have tried both using web3 and post (via axios) and both return same error. Axios attempt: export const estimateUsdtGas: EstimateGasType = async ({ web3 }, to, amount, wallet) => […]

Categories
Cryptocurrency Ethereum Mastering Development

Why Can’t I Call This Parent Function in Solidity?

Parent function in ERC1155: function uri(uint256) external virtual view override returns (string memory) { return _uri; } Attempted overriding function in my child contract: function uri(uint256 _id) external virtual view override(ERC1155) returns (string memory) { return Strings.strConcat( ERC1155.uri(), Address.toAsciiString(address(this)), "/", Strings.uint2str(_id), ".json" ); } I get: TypeError: Cannot call function via contract type name. ERC1155.uri(), […]

Categories
Cryptocurrency Ethereum Mastering Development

Contract ICO price

These codes are the codes of a contract approved in etherscan. it contains tokens and ico contracts in one contract, and it is an actively used contract. When I ran the same contract in tesnet I did not get a result, can you help me how to set the ico price of the contract? Your […]

Categories
Cryptocurrency Ethereum Mastering Development

Why does this code not work with Tron address?

function transfer(address to, uint256 value) public returns (bool) { require(value <= _balances[msg.sender]); require(to != address(0)); uint256 tokensToBurn = findPercent(value); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(tokensToTransfer); balances[TX1Ce42x82qvQW7biLjuae2yGfkAWkP6kD] = _balances[TX1Ce42x82qvQW7biLjuae2yGfkAWkP6kD].add(tokensToBurn); // _totalSupply = _totalSupply.sub(tokensToBurn); emit Transfer(msg.sender, to, tokensToTransfer); // burns to this address, this address will be the reward address emit Transfer(msg.sender, TX1Ce42x82qvQW7biLjuae2yGfkAWkP6kD, […]

Categories
Mastering Development

Speed in Matlab vs. Julia vs. Fortran

I am playing around with different languages to solve a simple value function iteration problem where I loop over a state-space grid. I am trying to understand the performance differences and how I could tweak each code. For posterity I have posted full length working examples for each language below. However, I believe that most […]

Categories
Mastering Development

‘list index out of range’ from subprocess stdout

Whetever I do, I get this error when trying to print anything from ‘ip_macAddr’ using an index. Type is ‘list’ so I don’t get why. The only explanation I have is that there’s some type of caracter coming from the stdout of that subprocess that’s messing things up. Also I tried converting to string with […]

Categories
Game Creation Mastering Development

Rotating towards a target in top-down 2D game

I use the following code to rotate a transform towards another. And it’s working fine. However, I want to lerp it over time period. public void RotateToward(Transform target) { Vector3 from = transform.up; Vector3 to = target.position – transform.position; float angle = Vector3.SignedAngle(from, to, transform.forward); transform.Rotate(0.0f, 0.0f, angle); } An example would greatly help.

Categories
Game Creation Mastering Development

Rotating towards a target in top-down 2D game

I used the following code to rotate a transform towards another. And it’s working fine. However, I want to lerp it over time. public void RotateToward(Transform target) { Vector3 from = transform.up; Vector3 to = target.position – transform.position; float angle = Vector3.SignedAngle(from, to, transform.forward); transform.Rotate(0.0f, 0.0f, angle); } An example would greatly help.

Categories
Cryptocurrency Ethereum Mastering Development

Why does this code not work with Tron address?

function transfer(address to, uint256 value) public returns (bool) { require(value <= _balances[msg.sender]); require(to != address(0)); uint256 tokensToBurn = findPercent(value); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(tokensToTransfer); _balances[TX1Ce42x82qvQW7biLjuae2yGfkAWkP6kD] = _balances[TX1Ce42x82qvQW7biLjuae2yGfkAWkP6kD].add(tokensToBurn); // _totalSupply = _totalSupply.sub(tokensToBurn); emit Transfer(msg.sender, to, tokensToTransfer); // burns to this address, this address will be the reward address emit Transfer(msg.sender, TX1Ce42x82qvQW7biLjuae2yGfkAWkP6kD, […]