I am trying to create function using numpy something like f=(x-a1)^2+(y-a2)^2+a3

Where a1,a2,a3 are random generated numbers and x,y are parameters.

But I cant work with it, I want to find f(0,0) where [0,0] is [x,y] and [a1,a2,a3] were set before,but my code doesnt work.
And then I want to convert this function to tensorflow tensor.Here is my code, string with "##" dont work.

```
import tensorflow as tf
from random import random, seed
import numpy as np

def mypolyval(x, min_point, min_value):
    res = min_value
    for i in range(len(min_point)):
        res += (x[i] - min_point[i]) ** 2
    return res

class FunGen:
    def __init__(self, dim, n):
        self.dim = dim
        self.n = n
        self.functions = []
        self.x = []

    def c2(self):
        seed(10)
        for _ in range(self.n):
            min_point = [random() for _ in range(self.dim)]
            min_value = random()
            f = np.vectorize(mypolyval, excluded=['x'])

            ##print(f(x=np.array([0, 0]), min_point=min_point, min_value=min_value))
            self.functions.append((f, min_point, min_value))
        return self.functions

functions = FunGen(2, 1).c2()
for i in functions:
    print(type(i[0]))
    f=i[0]
   ## print(f(x=[0, 0], min_value=i[1], min_point=i[2]))
    ##a=tf.convert_to_tensor(f,dtype=np.float32)

```
['https://Stackoverflow.com/questions/48735135', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8895598/']
You should use web3 provider like MetaMask in browser.
This is script that I use for web3 detection:

```
window.addEventListener('load', function () {
    if (typeof web3 !== 'undefined') {        
        window.web3 = new Web3(window.web3.currentProvider)

        if (window.web3.currentProvider.isMetaMask === true) {
            window.web3.eth.getAccounts((error, accounts) => {
                if (accounts.length == 0) {
                    // there is no active accounts in MetaMask
                }
                else {
                    // It's ok
                }
            });
        } else {
            // Another web3 provider
        }
    } else {
        // No web 3 provider
    }    
});

```
To new readers that want to fix this issue, as of [January 2021, Metamask has removed it's injected `window.web3` API](https://docs.metamask.io/guide/provider-migration.html#provider-migration-guide). To use connect your app to Metamask, I'd try something like this

```
export const connectWallet = async () => {
  if (window.ethereum) { //check if Metamask is installed
        try {
            const address = await window.ethereum.enable(); //connect Metamask
            const obj = {
                    connectedStatus: true,
                    status: "",
                    address: address
                }
                return obj;

        } catch (error) {
            return {
                connectedStatus: false,
                status: " Connect to Metamask using the button on the top right."
            }
        }

  } else {
        return {
            connectedStatus: false,
            status: " You must install Metamask into your browser: https://metamask.io/download.html"
        }
      } 
};

```

In [this tutorial on creating an NFT Minter with React](https://docs.alchemyapi.io/alchemy/tutorials/nft-minter), you can also learn how to call smart contract functions and sign transactions via Metamask! Best of luck :)